From 22df1b87af5833f516bf7cdb7ed46f3dda32a2ae Mon Sep 17 00:00:00 2001 From: raven42 Date: Mon, 21 Sep 2020 08:24:01 -0500 Subject: [PATCH 1/5] Fix for #647: Add g:tagbar_wrap option --- autoload/tagbar.vim | 11 ++++++++++- doc/tagbar.txt | 16 ++++++++++++++++ plugin/tagbar.vim | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index ca0fdd0..5736eb7 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -954,10 +954,19 @@ function! s:InitWindow(autoclose) abort " Window-local options setlocal nolist - setlocal nowrap setlocal winfixwidth setlocal nospell + if g:tagbar_wrap == 0 + setlocal nowrap + else + setlocal wrap + if exists('+linebreak') + setlocal breakindent + setlocal breakindentopt=shift:4 + endif + endif + if g:tagbar_show_linenumbers == 0 setlocal nonumber if exists('+relativenumber') diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 757c9f3..8ace2d5 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -882,6 +882,22 @@ Example: > let g:tagbar_use_cache = 0 < + *g:tagbar_wrap* +g:tagbar_wrap~ +Default: 0 + +If set to non-zero, this will enable line wrapping on the tagbar window. This +option will use the built-in |wrap| vim option on the tagbar window to +enable line wrapping. This also will use the |breakindent| and +|breakindentopt| options in vim to set the indentation of the wrapped lines. + +Note: This requires VIM to be compiled with the |+linebreak| option for the +wrap intentation to function. + +Example: +> + let g:tagbar_wrap = 1 +> ------------------------------------------------------------------------------ HIGHLIGHT COLOURS *tagbar-highlight* diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 7fb69a3..58d53a8 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -109,6 +109,7 @@ function! s:setup_options() abort \ ['zoomwidth', 1], \ ['silent', 0], \ ['use_cache', 1], + \ ['wrap', 0], \ ] for [opt, val] in options From 88be6d9a4c78b8892a6a39fe7e4570e4574f865a Mon Sep 17 00:00:00 2001 From: raven42 Date: Mon, 21 Sep 2020 08:25:57 -0500 Subject: [PATCH 2/5] Fix syntax in example text for new option --- doc/tagbar.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 8ace2d5..5a8d0cb 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -897,7 +897,7 @@ wrap intentation to function. Example: > let g:tagbar_wrap = 1 -> +< ------------------------------------------------------------------------------ HIGHLIGHT COLOURS *tagbar-highlight* From 5339b4e8bd69e06ca4857cc07fc3fb7d0366001c Mon Sep 17 00:00:00 2001 From: Luis Piloto Date: Wed, 23 Sep 2020 11:02:34 +0100 Subject: [PATCH 3/5] Add g:tagbar_scopestrs (#661) Allows mapping scope suffixes (e.g. 'function') to user-defined values. --- autoload/tagbar/prototypes/normaltag.vim | 12 ++++++++- doc/tagbar.txt | 32 ++++++++++++++++++++++++ plugin/tagbar.vim | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar/prototypes/normaltag.vim b/autoload/tagbar/prototypes/normaltag.vim index d212c62..d759b2f 100644 --- a/autoload/tagbar/prototypes/normaltag.vim +++ b/autoload/tagbar/prototypes/normaltag.vim @@ -1,3 +1,12 @@ +function! s:maybe_map_scope(scopestr) abort + if !empty(g:tagbar_scopestrs) + if has_key(g:tagbar_scopestrs, a:scopestr) + return g:tagbar_scopestrs[a:scopestr] + endif + endif + return a:scopestr +endfunction + function! tagbar#prototypes#normaltag#new(name) abort let newobj = tagbar#prototypes#basetag#new(a:name) @@ -22,7 +31,8 @@ function! s:strfmt() abort dict if has_key(self.fields, 'type') let suffix .= ' : ' . self.fields.type elseif has_key(get(typeinfo, 'kind2scope', {}), self.fields.kind) - let suffix .= ' : ' . typeinfo.kind2scope[self.fields.kind] + let scope = s:maybe_map_scope(typeinfo.kind2scope[self.fields.kind]) + let suffix .= ' : ' . scope endif return self._getPrefix() . self.name . suffix diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 5a8d0cb..486cd44 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -733,6 +733,38 @@ just choose other characters in that case): let g:tagbar_iconchars = ['▸', '▾'] let g:tagbar_iconchars = ['▷', '◢'] let g:tagbar_iconchars = ['+', '-'] (default on Windows) +< + *g:tagbar_scopestrs* +g:tagbar_scopestrs~ +Default: {} + +Setting to replace a tag's scope with a user-specified string in Tagbar's +display. If a scope is found in the keys of |g:tagbar_scopestrs|, then the +scope will be displayed as the corresponding value. If the scope is not +found, then the scope will be displayed as normal. + +Example (don't worry if some of the characters aren't displayed correctly, +just choose other characters or strings in that case): +> + let g:tagbar_scopestrs = { + \ 'class': "\uf0e8", + \ 'const': "\uf8ff", + \ 'constant': "\uf8ff", + \ 'enum': "\uf702", + \ 'field': "\uf30b", + \ 'func': "\uf794", + \ 'function': "\uf794", + \ 'getter': "\ufab6", + \ 'implementation': "\uf776", + \ 'interface': "\uf7fe", + \ 'map': "\ufb44", + \ 'member': "\uf02b", + \ 'method': "\uf6a6", + \ 'setter': "\uf7a9", + \ 'variable': "\uf71b", + \ } + + < *g:tagbar_autoshowtag* diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 58d53a8..3b1bc31 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -95,6 +95,7 @@ function! s:setup_options() abort \ ['hide_nonpublic', 0], \ ['height', 10], \ ['indent', 2], + \ ['scopestrs', {}], \ ['left', 0], \ ['position', default_pos], \ ['previewwin_pos', previewwin_pos], From 8d17340295f412f5dff04fcbbd47b5b86351045c Mon Sep 17 00:00:00 2001 From: Luis Piloto Date: Wed, 23 Sep 2020 11:43:05 +0100 Subject: [PATCH 4/5] Add g:tagbar_visibility_symbols (#660) --- autoload/tagbar/prototypes/basetag.vim | 3 +++ doc/tagbar.txt | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar/prototypes/basetag.vim b/autoload/tagbar/prototypes/basetag.vim index 2095271..2f411bf 100644 --- a/autoload/tagbar/prototypes/basetag.vim +++ b/autoload/tagbar/prototypes/basetag.vim @@ -3,6 +3,9 @@ let s:visibility_symbols = { \ 'protected' : '#', \ 'private' : '-' \ } +if !empty(g:tagbar_visibility_symbols) + let s:visibility_symbols = g:tagbar_visibility_symbols +endif function! tagbar#prototypes#basetag#new(name) abort let newobj = {} diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 486cd44..cd73a2d 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -646,7 +646,21 @@ name. Example: > let g:tagbar_show_visibility = 0 -< + + *g:tagbar_visibility_symbols* +g:tagbar_visibility_symbols +Default: { 'public' : '+', 'protected' : '#', 'private' : '-' } + +Symbols to use for visibility (public/protected/private) to the left of the tag +name. See |g:tagbar_show_visibility|. + +Example: +> + let g:tagbar_visibility_symbols = { + \ 'public' : '+', + \ 'protected' : '#', + \ 'private' : '-' + \ } *g:tagbar_show_linenumbers* g:tagbar_show_linenumbers~ From 259b47a691fd765a9870e16b40200080e8de7979 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 23 Sep 2020 17:09:33 +0300 Subject: [PATCH 5/5] Fix vimscript snafu from #660, closes #662 --- autoload/tagbar/prototypes/basetag.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/tagbar/prototypes/basetag.vim b/autoload/tagbar/prototypes/basetag.vim index 2f411bf..d002afa 100644 --- a/autoload/tagbar/prototypes/basetag.vim +++ b/autoload/tagbar/prototypes/basetag.vim @@ -3,7 +3,7 @@ let s:visibility_symbols = { \ 'protected' : '#', \ 'private' : '-' \ } -if !empty(g:tagbar_visibility_symbols) +if exists('g:tagbar_visibility_symbols') && !empty(g:tagbar_visibility_symbols) let s:visibility_symbols = g:tagbar_visibility_symbols endif