diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 69e3a11..7edc25d 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1208,10 +1208,12 @@ function! s:BaseTag._getPrefix() abort dict let prefix = ' ' endif " Visibility is called 'access' in the ctags output - if has_key(self.fields, 'access') - let prefix .= get(s:visibility_symbols, self.fields.access, ' ') - else - let prefix .= ' ' + if g:tagbar_show_visibility + if has_key(self.fields, 'access') + let prefix .= get(s:visibility_symbols, self.fields.access, ' ') + else + let prefix .= ' ' + endif endif return prefix @@ -2514,7 +2516,10 @@ function! s:PrintKinds(typeinfo, fileinfo) abort " only if they are not scope-defining tags (since " those already have an identifier) if !has_key(a:typeinfo.kind2scope, ckind.short) - silent put =repeat(' ', g:tagbar_indent + 2) . + let indent = g:tagbar_indent + let indent += g:tagbar_show_visibility + let indent += 1 " fold symbol + silent put =repeat(' ', indent) . \ '[' . ckind.long . ']' " Add basic tag to allow folding when on the " header line @@ -2547,10 +2552,11 @@ function! s:PrintKinds(typeinfo, fileinfo) abort let foldmarker = s:icon_open endif + let padding = g:tagbar_show_visibility ? ' ' : '' if g:tagbar_compact && first_tag && s:short_help - silent 0put =foldmarker . ' ' . kind.long + silent 0put =foldmarker . padding . kind.long else - silent put =foldmarker . ' ' . kind.long + silent put =foldmarker . padding . kind.long endif let curline = line('.') @@ -2601,7 +2607,10 @@ function! s:PrintTag(tag, depth, fileinfo, typeinfo) abort " are not scope-defining tags (since those already have an " identifier) if !has_key(a:typeinfo.kind2scope, ckind.short) - silent put =repeat(' ', (a:depth + 1) * g:tagbar_indent + 2) + let indent = g:tagbar_indent + let indent += g:tagbar_show_visibility + let indent += 1 " fold symbol + silent put =repeat(' ', (a:depth + 1) * indent) \ . '[' . ckind.long . ']' " Add basic tag to allow folding when on the header line let headertag = s:BaseTag.New(ckind.long) diff --git a/doc/tagbar.txt b/doc/tagbar.txt index a63dbd2..2ed4f60 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -431,6 +431,18 @@ Example: let g:tagbar_indent = 1 < + *g:tagbar_show_visibility* +g:tagbar_show_visibility~ +Default: 1 + +Show the visibility symbols (public/protected/private) to the left of the tag +name. + +Example: +> + let g:tagbar_show_visibility = 0 +< + *g:tagbar_expand* g:tagbar_expand~ Default: 0 diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index cdb4cac..a594cb4 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -70,6 +70,10 @@ if !exists('g:tagbar_indent') let g:tagbar_indent = 2 endif +if !exists('g:tagbar_show_visibility') + let g:tagbar_show_visibility = 1 +endif + if !exists('g:tagbar_expand') let g:tagbar_expand = 0 endif diff --git a/syntax/tagbar.vim b/syntax/tagbar.vim index dac8f50..5c7fd20 100644 --- a/syntax/tagbar.vim +++ b/syntax/tagbar.vim @@ -20,13 +20,13 @@ if s:io =~ '[]^\\-]' let s:io = '\' . s:io endif -let s:pattern = '\([' . s:ic . s:io . '] \)\@<=[^-+: ]\+[^:]\+$' +let s:pattern = '\([' . s:ic . s:io . '] \?\)\@<=[^-+: ]\+[^:]\+$' execute "syntax match TagbarKind '" . s:pattern . "'" -let s:pattern = '\([' . s:ic . s:io . '][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@=' +let s:pattern = '\([' . s:ic . s:io . '][-+# ]\?\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@=' execute "syntax match TagbarScope '" . s:pattern . "'" -let s:pattern = '[' . s:ic . s:io . ']\([-+# ]\)\@=' +let s:pattern = '[' . s:ic . s:io . ']\([-+# ]\?\)\@=' execute "syntax match TagbarFoldIcon '" . s:pattern . "'" let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=+\([^-+# ]\)\@='