Support lazy loading with :packadd.

Vim recently has introduced a new feature called 'packages', which
permits, among the rest, to disable automatic loading a plugin at
startup. Plugins that are disabled at startup may be manually loaded
during a session using :packadd (see :h packages, :h :packadd). Of
course, a plugin that is loaded after startup cannot rely on VimEnter
events.

In order to support lazy loading YCM, check whether YCM is sourced
during startup or at a later time. In the former case, define an
autocommand as before; in the latter case, enable YCM immediately.
This commit is contained in:
Lifepillar 2016-03-26 21:11:11 +02:00
parent 429e04ab98
commit bf63188066

View File

@ -165,10 +165,14 @@ let g:ycm_disable_for_files_larger_than_kb =
" On-demand loading. Let's use the autoload folder and not slow down vim's " On-demand loading. Let's use the autoload folder and not slow down vim's
" startup procedure. " startup procedure.
augroup youcompletemeStart if has( 'vim_starting' ) " loading at startup
augroup youcompletemeStart
autocmd! autocmd!
autocmd VimEnter * call youcompleteme#Enable() autocmd VimEnter * call youcompleteme#Enable()
augroup END augroup END
else " manual loading with :packadd
call youcompleteme#Enable()
endif
" This is basic vim plugin boilerplate " This is basic vim plugin boilerplate
call s:restore_cpo() call s:restore_cpo()