|
@@ -45,6 +45,11 @@ let s:pollers = {
|
|
|
\ 'wait_milliseconds': 100
|
|
|
\ }
|
|
|
\ }
|
|
|
+let s:buftype_blacklist = {
|
|
|
+ \ 'help': 1,
|
|
|
+ \ 'terminal': 1,
|
|
|
+ \ 'quickfix': 1
|
|
|
+ \ }
|
|
|
|
|
|
|
|
|
" When both versions are available, we prefer Python 3 over Python 2:
|
|
@@ -132,7 +137,7 @@ function! youcompleteme#Enable()
|
|
|
" filetype) and if so, the FileType event has triggered before and thus the
|
|
|
" buffer is already parsed.
|
|
|
autocmd FileType * call s:OnFileTypeSet()
|
|
|
- autocmd BufEnter * call s:OnBufferEnter()
|
|
|
+ autocmd BufEnter,CmdwinEnter * call s:OnBufferEnter()
|
|
|
autocmd BufUnload * call s:OnBufferUnload()
|
|
|
autocmd InsertLeave * call s:OnInsertLeave()
|
|
|
autocmd VimLeave * call s:OnVimLeave()
|
|
@@ -428,23 +433,23 @@ endfunction
|
|
|
|
|
|
|
|
|
function! s:AllowedToCompleteInBuffer( buffer )
|
|
|
- let buffer_filetype = getbufvar( a:buffer, '&filetype' )
|
|
|
+ let buftype = getbufvar( a:buffer, '&buftype' )
|
|
|
|
|
|
- if empty( buffer_filetype ) ||
|
|
|
- \ getbufvar( a:buffer, '&buftype' ) ==# 'nofile' ||
|
|
|
- \ buffer_filetype ==# 'qf'
|
|
|
+ if has_key( s:buftype_blacklist, buftype )
|
|
|
return 0
|
|
|
endif
|
|
|
|
|
|
- if s:DisableOnLargeFile( a:buffer )
|
|
|
+ let filetype = getbufvar( a:buffer, '&filetype' )
|
|
|
+
|
|
|
+ if empty( filetype ) || s:DisableOnLargeFile( a:buffer )
|
|
|
return 0
|
|
|
endif
|
|
|
|
|
|
let whitelist_allows = type( g:ycm_filetype_whitelist ) != type( {} ) ||
|
|
|
\ has_key( g:ycm_filetype_whitelist, '*' ) ||
|
|
|
- \ has_key( g:ycm_filetype_whitelist, buffer_filetype )
|
|
|
+ \ has_key( g:ycm_filetype_whitelist, filetype )
|
|
|
let blacklist_allows = type( g:ycm_filetype_blacklist ) != type( {} ) ||
|
|
|
- \ !has_key( g:ycm_filetype_blacklist, buffer_filetype )
|
|
|
+ \ !has_key( g:ycm_filetype_blacklist, filetype )
|
|
|
|
|
|
let allowed = whitelist_allows && blacklist_allows
|
|
|
if allowed
|
|
@@ -528,6 +533,13 @@ endfunction
|
|
|
|
|
|
|
|
|
function! s:OnFileTypeSet()
|
|
|
+ " The contents of the command-line window are empty when the filetype is set
|
|
|
+ " for the first time. Users should never change its filetype so we only rely
|
|
|
+ " on the CmdwinEnter event for that window.
|
|
|
+ if !empty( getcmdwintype() )
|
|
|
+ return
|
|
|
+ endif
|
|
|
+
|
|
|
if !s:AllowedToCompleteInCurrentBuffer()
|
|
|
return
|
|
|
endif
|