Make visibility symbols optional

This commit is contained in:
Jan Larres 2012-11-22 18:42:14 +13:00
parent 0ab07ac566
commit 7d836e0c53
4 changed files with 36 additions and 11 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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 . ' ]\)\@<=+\([^-+# ]\)\@='