From 00841836b4559ddc793dd62dfaa506b0919dc910 Mon Sep 17 00:00:00 2001 From: raven42 Date: Thu, 29 Oct 2020 10:36:47 -0500 Subject: [PATCH] Add g:tagbar_scrolloff configuration (#692) * Add g:tagbar_scroll_offset configuration Closes #564 Add option for `g:tagbar_scrolloff` to issue a `setlocal scrolloff=#` during tagbar window init * Address review comments --- autoload/tagbar.vim | 4 ++++ doc/tagbar.txt | 15 +++++++++++++++ plugin/tagbar.vim | 1 + 3 files changed, 20 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 2a3dd4b..54786af 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -947,6 +947,10 @@ function! s:InitWindow(autoclose) abort setlocal nomodifiable setlocal textwidth=0 + if g:tagbar_scrolloff > 0 + execute 'setlocal scrolloff=' . g:tagbar_scrolloff + endif + if g:tagbar_show_balloon == 1 && has('balloon_eval') setlocal balloonexpr=TagbarBalloonExpr() set ballooneval diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 581f43f..9a32190 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -1025,6 +1025,21 @@ Example: > let g:tagbar_wrap = 1 < + *g:tagbar_scrolloff* +g:tagbar_scrolloff~ +Default: 0 + +If set to non-zero, the tagbar window initialization will set the |scrolloff| +value local to the tagbar window to the specified value. This is used to +position the current tag in the tagbar window. See the help for |scrolloff| +for more details. If set to a very high value (greater than the height of the +tagbar window), then the current tag should always stay in the center of the +tagbar window. + +Example: +> + let g:tagbar_scrolloff = 10 +< ------------------------------------------------------------------------------ HIGHLIGHT COLOURS *tagbar-highlight* diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 8edef9d..a995418 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -101,6 +101,7 @@ function! s:setup_options() abort \ ['position', default_pos], \ ['previewwin_pos', previewwin_pos], \ ['scopestrs', {}], + \ ['scrolloff', 0], \ ['show_balloon', 1], \ ['show_visibility', 1], \ ['show_linenumbers', 0],