Always defer loading at VimEnter

YCM should start the same whether Vim is running in GUI or not. Otherwise, this
makes it difficult for other plugins to interact with YCM at startup because
they can't predict how YCM will start unless they also check if Vim is running
in GUI which is unreasonable. Since we can't load it at Vim startup because of
a deadlock issue, we should always defer it at the VimEnter event.
This commit is contained in:
micbou 2017-03-02 21:48:56 +01:00
parent 39659caf34
commit c31152d345
No known key found for this signature in database
GPG Key ID: C7E8FD1F3BDA1E05

View File

@ -128,7 +128,7 @@ let g:ycm_goto_buffer_command =
let g:ycm_disable_for_files_larger_than_kb = let g:ycm_disable_for_files_larger_than_kb =
\ get( g:, 'ycm_disable_for_files_larger_than_kb', 1000 ) \ get( g:, 'ycm_disable_for_files_larger_than_kb', 1000 )
if has( 'vim_starting' ) && has( 'gui_running' ) " Loading at startup, in gui. if has( 'vim_starting' ) " Loading at startup.
" We defer loading until after VimEnter to allow the gui to fork (see " We defer loading until after VimEnter to allow the gui to fork (see
" `:h gui-fork`) and avoid a deadlock situation, as explained here: " `:h gui-fork`) and avoid a deadlock situation, as explained here:
" https://github.com/Valloric/YouCompleteMe/pull/2473#issuecomment-267716136 " https://github.com/Valloric/YouCompleteMe/pull/2473#issuecomment-267716136
@ -136,7 +136,7 @@ if has( 'vim_starting' ) && has( 'gui_running' ) " Loading at startup, in gui.
autocmd! autocmd!
autocmd VimEnter * call youcompleteme#Enable() autocmd VimEnter * call youcompleteme#Enable()
augroup END augroup END
else " Manual loading with :packadd, or not starting the gui. else " Manual loading with :packadd.
call youcompleteme#Enable() call youcompleteme#Enable()
endif endif