Browse files

Make visibility symbols optional

  • Loading branch information...
1 parent 0ab07ac commit 7d836e0c53f82aa1b71ed934601af8ccfdc2d820 @majutsushi committed Nov 22, 2012
Showing with 36 additions and 11 deletions.
  1. +17 −8 autoload/tagbar.vim
  2. +12 −0 doc/tagbar.txt
  3. +4 −0 plugin/tagbar.vim
  4. +3 −3 syntax/tagbar.vim
View
25 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)
View
12 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
View
4 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
View
6 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 . ' ]\)\@<=+\([^-+# ]\)\@='

0 comments on commit 7d836e0

Please sign in to comment.