From c22e425e25dbcbbd6f8f2d724bf9fb71bf550f15 Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Tue, 13 Dec 2016 23:43:39 -0800 Subject: [PATCH 1/2] Remove non-lazy lazy loading code As discussed in https://github.com/Valloric/YouCompleteMe/pull/2454, this code doesn't do what it claims to do on the surface, so we should delete it. I'll follow up with a commit to explain in the README how to actually defer loading of the plug-in. --- plugin/youcompleteme.vim | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index ac0f88ab..5b37d515 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -128,16 +128,7 @@ let g:ycm_goto_buffer_command = let g:ycm_disable_for_files_larger_than_kb = \ get( g:, 'ycm_disable_for_files_larger_than_kb', 1000 ) -" On-demand loading. Let's use the autoload folder and not slow down vim's -" startup procedure. -if has( 'vim_starting' ) " loading at startup - augroup youcompletemeStart - autocmd! - autocmd VimEnter * call youcompleteme#Enable() - augroup END -else " manual loading with :packadd - call youcompleteme#Enable() -endif +call youcompleteme#Enable() " This is basic vim plugin boilerplate call s:restore_cpo() From 7f76b03e0e21effd702da174998ac48bb44f43c4 Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Tue, 13 Dec 2016 23:51:40 -0800 Subject: [PATCH 2/2] doc: Add FAQ entry explaining how to defer loading --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 3936b85c..fc568057 100644 --- a/README.md +++ b/README.md @@ -2882,6 +2882,19 @@ executable first in your PATH when the virtual environment is active then if you set `g:ycm_python_binary_path` to just `'python'` it will be found as the first Python and used to run [JediHTTP][]. +### I want to defer loading of YouCompleteMe until after Vim finishes booting + +In recent versions of Vim, you can install YCM in a folder under +`~/.vim/pack/*/opt` and then load it once the user is idle via an autocommand: + +```viml +augroup load_ycm + autocmd! + autocmd CursorHold, CursorHoldI * :packadd YouCompleteMe + \ | autocmd! load_ycm +augroup END +``` + Contributor Code of Conduct ---------------------------