1
0
mirror of https://github.com/gryf/tagbar.git synced 2025-12-17 11:30:28 +01:00

Display 'kind' headers inside of scopes

This commit is contained in:
Jan Larres
2011-11-24 19:22:31 +13:00
parent 20ff7303a6
commit 555be533a4
3 changed files with 48 additions and 16 deletions

View File

@@ -1078,6 +1078,7 @@ function! s:BaseTag.closeFold() dict
elseif self.isFoldable() && !self.isFolded()
" Tag is parent of a scope and is not folded
let self.fileinfo.tagfolds[self.fields.kind][self.fullpath] = 1
let newline = self.tline
elseif !empty(self.parent)
" Tag is normal child, so close parent
let parent = self.parent
@@ -2139,9 +2140,22 @@ function! s:PrintKinds(typeinfo, fileinfo)
let tag.tline = curline
let a:fileinfo.tline[curline] = tag
" Print children
if tag.isFoldable() && !tag.isFolded()
for childtag in tag.children
call s:PrintTag(childtag, 1, a:fileinfo, a:typeinfo)
for ckind in a:typeinfo.kinds
let childtags = filter(copy(tag.children),
\ 'v:val.fields.kind ==# ckind.short')
if len(childtags) > 0
" Print 'kind' header of following children
if !has_key(a:typeinfo.kind2scope, ckind.short)
silent put =' [' . ckind.long . ']'
let a:fileinfo.tline[line('.')] = tag
endif
for childtag in childtags
call s:PrintTag(childtag, 1,
\ a:fileinfo, a:typeinfo)
endfor
endif
endfor
endif
@@ -2207,8 +2221,21 @@ function! s:PrintTag(tag, depth, fileinfo, typeinfo)
" Recursively print children
if a:tag.isFoldable() && !a:tag.isFolded()
for childtag in a:tag.children
call s:PrintTag(childtag, a:depth + 1, a:fileinfo, a:typeinfo)
for ckind in a:typeinfo.kinds
let childtags = filter(copy(a:tag.children),
\ 'v:val.fields.kind ==# ckind.short')
if len(childtags) > 0
" Print 'kind' header of following children
if !has_key(a:typeinfo.kind2scope, ckind.short)
silent put =' ' . repeat(' ', a:depth * 2) .
\ '[' . ckind.long . ']'
let a:fileinfo.tline[line('.')] = a:tag
endif
for childtag in childtags
call s:PrintTag(childtag, a:depth + 1,
\ a:fileinfo, a:typeinfo)
endfor
endif
endfor
endif
endfunction

View File

@@ -488,6 +488,9 @@ TagbarComment
TagbarKind
The header of generic "kinds" like "functions" and "variables".
TagbarNestedKind
The "kind" headers in square brackets inside of scopes.
TagbarScope
Tags that define a scope like classes, structs etc.

View File

@@ -41,19 +41,21 @@ else
syntax match TagbarAccessPrivate '\([-+ ]\)\@<=-\([^-+# ]\)\@='
endif
syntax match TagbarComment '^".*'
syntax match TagbarType ' : \zs.*'
syntax match TagbarSignature '(.*)'
syntax match TagbarPseudoID '\*\ze :'
syntax match TagbarNestedKind '^\s\+\[[^]]\+\]$'
syntax match TagbarComment '^".*'
syntax match TagbarType ' : \zs.*'
syntax match TagbarSignature '(.*)'
syntax match TagbarPseudoID '\*\ze :'
highlight default link TagbarComment Comment
highlight default link TagbarKind Identifier
highlight default link TagbarScope Title
highlight default link TagbarType Type
highlight default link TagbarSignature SpecialKey
highlight default link TagbarPseudoID NonText
highlight default link TagbarFoldIcon Statement
highlight default link TagbarHighlight Search
highlight default link TagbarComment Comment
highlight default link TagbarKind Identifier
highlight default link TagbarNestedKind TagbarKind
highlight default link TagbarScope Title
highlight default link TagbarType Type
highlight default link TagbarSignature SpecialKey
highlight default link TagbarPseudoID NonText
highlight default link TagbarFoldIcon Statement
highlight default link TagbarHighlight Search
highlight default TagbarAccessPublic guifg=Green ctermfg=Green
highlight default TagbarAccessProtected guifg=Blue ctermfg=Blue