Add g:tagbar_highlight_follow_insert option (#725)

This adds an option making the highlight in the Tagbar follow the cursor
in insert mode as well. This feature is guarded behind an option because
it may introduce some delay in the input.

GitHub: closes #724
This commit is contained in:
pacien 2021-01-11 14:24:49 +01:00 committed by GitHub
parent 778d41f437
commit 6f02f1f852
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -576,6 +576,10 @@ function! s:CreateAutocommands() abort
" was changed by an external command; see commit 17d199f
autocmd BufReadPost,BufEnter,CursorHold,FileType * call
\ s:AutoUpdate(fnamemodify(expand('<afile>'), ':p'), 0)
if g:tagbar_highlight_follow_insert
autocmd CursorHoldI * call
\ s:AutoUpdate(fnamemodify(expand('<afile>'), ':p'), 0)
endif
autocmd BufDelete,BufWipeout *
\ nested call s:HandleBufDelete(expand('<afile>'), expand('<abuf>'))

View File

@ -1094,6 +1094,19 @@ containing the tag without scrolling the window. If the tag is not visible
in the window then the window will be scrolled and the tag (and cursor)
placed in the location dictated by |g:tagbar_jump_offset|.
*g:tagbar_highlight_follow_insert*
g:tagbar_highlight_follow_insert~
Default: 0
If set to non-zero, the highlight of the current tag in the Tagbar will follow
the cursor in insert mode as well, after a short pause once the cursor stops
moving. Enabling this option may introduce some lag during the input, so it is
disabled by default.
Example:
>
let g:tagbar_highlight_follow_insert = 1
<
*g:tagbar_highlight_method*
g:tagbar_highlight_method~
Default: 'nearest-stl'

View File

@ -100,6 +100,7 @@ function! s:setup_options() abort
\ ['jump_lazy_scroll', 0],
\ ['left', 0],
\ ['help_visibility', 0],
\ ['highlight_follow_insert', 0],
\ ['highlight_method', 'nearest-stl'],
\ ['ignore_anonymous', 0],
\ ['position', default_pos],