mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-17 11:30:28 +01:00
Add option to not trigger update on large files
This commit is contained in:
@@ -1158,6 +1158,20 @@ function! s:ProcessFile(fname, ftype) abort
|
||||
return
|
||||
endif
|
||||
|
||||
" If the file size limit it set, then check the linecount to see if
|
||||
" this file should be ignored or not.
|
||||
if g:tagbar_file_size_limit > 0
|
||||
let linecount = line('$')
|
||||
if linecount > g:tagbar_file_size_limit && !exists('b:tagbar_force_update')
|
||||
call tagbar#debug#log('[ProcessFile] File size too large (' . linecount . ' lines) - limit set to ' . g:tagbar_file_size_limit)
|
||||
if !exists('b:tagbar_file_exceeds_limit')
|
||||
echom 'File size too large (' . linecount . ' lines) - Not processing file (see help for g:tagbar_file_size_limit).'
|
||||
let b:tagbar_file_exceeds_limit = 1
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
let typeinfo = s:known_types[a:ftype]
|
||||
|
||||
" If the file has only been updated preserve the fold states, otherwise
|
||||
@@ -3578,6 +3592,16 @@ function! tagbar#Update() abort
|
||||
call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0)
|
||||
endfunction
|
||||
|
||||
" tagbar#ForceUpdate() {{{2
|
||||
function! tagbar#ForceUpdate() abort
|
||||
if !exists('b:tagbar_force_update')
|
||||
let b:tagbar_force_update = 1
|
||||
call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 1)
|
||||
unlet b:tagbar_force_update
|
||||
unlet b:tagbar_file_exceeds_limit
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" tagbar#toggle_pause() {{{2
|
||||
function! tagbar#toggle_pause() abort
|
||||
let s:paused = !s:paused
|
||||
|
||||
@@ -337,6 +337,10 @@ FUNCTIONS *tagbar-functions*
|
||||
return tag . ' --- ' . lines . ' lines'
|
||||
endfunction
|
||||
<
|
||||
*tagbar#ForceUpdate()*
|
||||
Forcefully update a file even if it exceeds the |g:tagbar_file_size_limit|
|
||||
value. This also clears the internal flags to the file will be re-examined
|
||||
again.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
KEY MAPPINGS *tagbar-keys*
|
||||
@@ -882,6 +886,21 @@ Example:
|
||||
>
|
||||
let g:tagbar_use_cache = 0
|
||||
<
|
||||
*g:tagbar_file_size_limit*
|
||||
g:tagbar_file_size_limit~
|
||||
Default: 0
|
||||
|
||||
By default, all files are processed by tagbar. Setting this value to non-zero
|
||||
will disable processing for any file with a line count greater than
|
||||
|g:tagbar_file_size_limit|. A message will be displayed once for a given buffer
|
||||
if the limit is exceeded. The file can be forcefully updated with the
|
||||
|tagbar#ForceUpdate()| function. If the value is set to 0, then the file will
|
||||
always be processed.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:tagbar_file_size_limit = 10000
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
HIGHLIGHT COLOURS *tagbar-highlight*
|
||||
|
||||
@@ -91,6 +91,7 @@ function! s:setup_options() abort
|
||||
\ ['case_insensitive', 0],
|
||||
\ ['compact', 0],
|
||||
\ ['expand', 0],
|
||||
\ ['file_size_limit', 0],
|
||||
\ ['foldlevel', 99],
|
||||
\ ['hide_nonpublic', 0],
|
||||
\ ['height', 10],
|
||||
|
||||
Reference in New Issue
Block a user