diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 5a69051d..eb85b41d 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -108,9 +108,7 @@ function! youcompleteme#Enable() if s:defer_omnifunc augroup ycm_defer_omnifunc autocmd! - autocmd InsertEnter * call s:SetOmnicompleteFunc() - \ | let s:defer_omnifunc = 0 - \ | autocmd! ycm_defer_omnifunc + autocmd InsertEnter * call s:DeferredUntilInsertEnter() augroup END endif @@ -121,6 +119,14 @@ function! youcompleteme#Enable() call s:OnBufferRead() endfunction +function s:DeferredUntilInsertEnter() + let s:defer_omnifunc = 0 + autocmd! ycm_defer_omnifunc + + if s:AllowedToCompleteInCurrentFile() + call s:SetOmnicompleteFunc() + endif +endfunction function! youcompleteme#EnableCursorMovedAutocommands() augroup ycmcompletemecursormove