diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 3a4428d..062129b 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -887,6 +887,10 @@ function! s:CreateAutocommands() autocmd BufUnload __Tagbar__ call s:CleanUp() autocmd CursorHold __Tagbar__ call s:ShowPrototype() + autocmd BufWritePost * + \ if line('$') < g:tagbar_updateonsave_maxlines | + \ call s:AutoUpdate(fnamemodify(expand(''), ':p')) | + \ endif autocmd BufEnter,CursorHold * call \ s:AutoUpdate(fnamemodify(expand(''), ':p')) autocmd BufDelete * call diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 6d4850a..d7bd8eb 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -432,6 +432,22 @@ Example: let g:tagbar_autoshowtag = 1 < + *g:tagbar_updateonsave_maxlines* +g:tagbar_updateonsave_maxlines~ +Default: 5000 + +If the current file has fewer lines than the value of this variable, Tagbar +will update immediately after saving the file. If it is longer then the update +will only happen on the |CursorHold| event and when switching buffers (or +windows). This is to prevent the time it takes to save a large file from +becoming annoying in case you have a slow computer. If you have a fast +computer you can set it to a higher value. + +Example: +> + let g:tagbar_updateonsave_maxlines = 10000 +< + *g:tagbar_systemenc* g:tagbar_systemenc~ Default: value of 'encoding' diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index be874d7..0e829ff 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -70,6 +70,10 @@ if !exists('g:tagbar_autoshowtag') let g:tagbar_autoshowtag = 0 endif +if !exists('g:tagbar_updateonsave_maxlines') + let g:tagbar_updateonsave_maxlines = 5000 +endif + if !exists('g:tagbar_systemenc') let g:tagbar_systemenc = &encoding endif