diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 6228050..9f619e6 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/autoload/tagbar/prototypes/basetag.vim b/autoload/tagbar/prototypes/basetag.vim index 2095271..d002afa 100644 --- a/autoload/tagbar/prototypes/basetag.vim +++ b/autoload/tagbar/prototypes/basetag.vim @@ -3,6 +3,9 @@ let s:visibility_symbols = { \ 'protected' : '#', \ 'private' : '-' \ } +if exists('g:tagbar_visibility_symbols') && !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/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 de551f4..afce89a 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -656,7 +656,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~ @@ -743,6 +757,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* @@ -892,6 +938,7 @@ Example: > let g:tagbar_use_cache = 0 < + *g:tagbar_file_size_limit* g:tagbar_file_size_limit~ Default: 0 @@ -908,6 +955,23 @@ Example: let g:tagbar_file_size_limit = 10000 < + *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 149abad..6f4b378 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -96,6 +96,7 @@ function! s:setup_options() abort \ ['hide_nonpublic', 0], \ ['height', 10], \ ['indent', 2], + \ ['scopestrs', {}], \ ['left', 0], \ ['position', default_pos], \ ['previewwin_pos', previewwin_pos], @@ -110,6 +111,7 @@ function! s:setup_options() abort \ ['zoomwidth', 1], \ ['silent', 0], \ ['use_cache', 1], + \ ['wrap', 0], \ ] for [opt, val] in options