From 6f02f1f8526d70ebd50e7c109869e4e87d759c73 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 11 Jan 2021 14:24:49 +0100 Subject: [PATCH] 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 --- autoload/tagbar.vim | 4 ++++ doc/tagbar.txt | 13 +++++++++++++ plugin/tagbar.vim | 1 + 3 files changed, 18 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index fdc9895..4d9dc61 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -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(''), ':p'), 0) + if g:tagbar_highlight_follow_insert + autocmd CursorHoldI * call + \ s:AutoUpdate(fnamemodify(expand(''), ':p'), 0) + endif autocmd BufDelete,BufWipeout * \ nested call s:HandleBufDelete(expand(''), expand('')) diff --git a/doc/tagbar.txt b/doc/tagbar.txt index cb29435..3350a8f 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -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' diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 75c1a00..68ef10f 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -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],