parent
4674bebe25
commit
e28c709b99
@ -1468,6 +1468,15 @@ Default: `'same-buffer'`
|
|||||||
|
|
||||||
let g:ycm_goto_buffer_command = 'same-buffer'
|
let g:ycm_goto_buffer_command = 'same-buffer'
|
||||||
|
|
||||||
|
### The `g:ycm_disable_for_files_larger_than_kb` option
|
||||||
|
|
||||||
|
Defines the max size (in Kb) for a file to be considered for completion. If this
|
||||||
|
option is set to 0 then no check is made on the size of the file you're opening
|
||||||
|
|
||||||
|
Default: 1000
|
||||||
|
|
||||||
|
let g:ycm_disable_for_files_larger_than_kb = 1000
|
||||||
|
|
||||||
FAQ
|
FAQ
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ function! youcompleteme#Enable()
|
|||||||
" We also need to trigger buf init code on the FileType event because when
|
" We also need to trigger buf init code on the FileType event because when
|
||||||
" the user does :enew and then :set ft=something, we need to run buf init
|
" the user does :enew and then :set ft=something, we need to run buf init
|
||||||
" code again.
|
" code again.
|
||||||
|
autocmd BufReadPre * call s:OnBufferReadPre( expand( '<afile>:p' ) )
|
||||||
autocmd BufRead,BufEnter,FileType * call s:OnBufferVisit()
|
autocmd BufRead,BufEnter,FileType * call s:OnBufferVisit()
|
||||||
autocmd BufUnload * call s:OnBufferUnload( expand( '<afile>:p' ) )
|
autocmd BufUnload * call s:OnBufferUnload( expand( '<afile>:p' ) )
|
||||||
autocmd CursorHold,CursorHoldI * call s:OnCursorHold()
|
autocmd CursorHold,CursorHoldI * call s:OnCursorHold()
|
||||||
@ -85,9 +86,10 @@ function! youcompleteme#Enable()
|
|||||||
autocmd VimLeave * call s:OnVimLeave()
|
autocmd VimLeave * call s:OnVimLeave()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Calling this once solves the problem of BufRead/BufEnter not triggering for
|
" Calling these once solves the problem of BufReadPre/BufRead/BufEnter not
|
||||||
" the first loaded file. This should be the last command executed in this
|
" triggering for the first loaded file. This should be the last commands
|
||||||
" function!
|
" executed in this function!
|
||||||
|
call s:OnBufferReadPre( expand( '<afile>:p' ) )
|
||||||
call s:OnBufferVisit()
|
call s:OnBufferVisit()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -285,6 +287,10 @@ function! s:AllowedToCompleteInCurrentFile()
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if exists( 'b:ycm_largefile' )
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
let whitelist_allows = has_key( g:ycm_filetype_whitelist, '*' ) ||
|
let whitelist_allows = has_key( g:ycm_filetype_whitelist, '*' ) ||
|
||||||
\ has_key( g:ycm_filetype_whitelist, &filetype )
|
\ has_key( g:ycm_filetype_whitelist, &filetype )
|
||||||
let blacklist_allows = !has_key( g:ycm_filetype_blacklist, &filetype )
|
let blacklist_allows = !has_key( g:ycm_filetype_blacklist, &filetype )
|
||||||
@ -347,6 +353,18 @@ function! s:OnVimLeave()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:OnBufferReadPre(filename)
|
||||||
|
let threshold = g:ycm_disable_for_files_larger_than_kb * 1024
|
||||||
|
|
||||||
|
if threshold > 0 && getfsize( a:filename ) > threshold
|
||||||
|
echohl WarningMsg |
|
||||||
|
\ echomsg "YouCompleteMe is disabled in this buffer; " .
|
||||||
|
\ "the file exceeded the max size (see YCM options)." |
|
||||||
|
\ echohl None
|
||||||
|
let b:ycm_largefile = 1
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:OnBufferVisit()
|
function! s:OnBufferVisit()
|
||||||
" We need to do this even when we are not allowed to complete in the current
|
" We need to do this even when we are not allowed to complete in the current
|
||||||
" file because we might be allowed to complete in the future! The canonical
|
" file because we might be allowed to complete in the future! The canonical
|
||||||
|
@ -167,6 +167,9 @@ let g:ycm_warning_symbol =
|
|||||||
let g:ycm_goto_buffer_command =
|
let g:ycm_goto_buffer_command =
|
||||||
\ get( g:, 'ycm_goto_buffer_command', 'same-buffer' )
|
\ get( g:, 'ycm_goto_buffer_command', 'same-buffer' )
|
||||||
|
|
||||||
|
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
|
" On-demand loading. Let's use the autoload folder and not slow down vim's
|
||||||
" startup procedure.
|
" startup procedure.
|
||||||
augroup youcompletemeStart
|
augroup youcompletemeStart
|
||||||
|
Loading…
Reference in New Issue
Block a user