mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-17 11:30:28 +01:00
Add g:tagbar_scopestrs (#661)
Allows mapping scope suffixes (e.g. 'function') to user-defined values.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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*
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user