From 8d8550cf5d5db7c60d3c4b5dfaa86ac022ee6c65 Mon Sep 17 00:00:00 2001 From: Roman Dobosz Date: Sun, 14 Feb 2016 13:41:29 +0100 Subject: [PATCH] Display the kind (type) of the tag on the status bar. Besides the usual tag hierarchy, type of the tag would be provided. --- autoload/tagbar.vim | 20 ++++++++++++++------ doc/tagbar.txt | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 34e3f48..870360f 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1400,7 +1400,7 @@ function! s:NormalTag.strfmt() abort dict endfunction " s:NormalTag.str() {{{3 -function! s:NormalTag.str(longsig, full) abort dict +function! s:NormalTag.str(longsig, full, showkind) abort dict if a:full && self.path != '' let str = self.path . self.typeinfo.sro . self.name else @@ -1413,6 +1413,10 @@ function! s:NormalTag.str(longsig, full) abort dict else let str .= '()' endif + elseif a:showkind + let str .= ' (' . + \ self.fileinfo.typeinfo.kind2scope[self.fields.kind] . + \ ')' endif return str @@ -4182,16 +4186,20 @@ function! tagbar#currenttag(fmt, default, ...) abort " Indicate that the statusline functionality is being used. This prevents " the CloseWindow() function from removing the autocommands. let s:statusline_in_use = 1 + let longsig = 0 + let fullpath = 0 + let prototype = 0 + let showkind = 0 if a:0 > 0 " also test for non-zero value for backwards compatibility let longsig = a:1 =~# 's' || (type(a:1) == type(0) && a:1 != 0) let fullpath = a:1 =~# 'f' let prototype = a:1 =~# 'p' - else - let longsig = 0 - let fullpath = 0 - let prototype = 0 + if a:1 =~# 'k' + let showkind = 1 + let fullpath = 1 + endif endif if !s:Init(1) @@ -4204,7 +4212,7 @@ function! tagbar#currenttag(fmt, default, ...) abort if prototype return tag.getPrototype(1) else - return printf(a:fmt, tag.str(longsig, fullpath)) + return printf(a:fmt, tag.str(longsig, fullpath, showkind)) endif else return a:default diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 898cdcc..85a7b57 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -828,6 +828,9 @@ tagbar#currenttag({format}, {default} [, {flags}]) 'p' Display the raw prototype instead of the parsed tag. This can be useful in cases where ctags doesn't report some information, like the signature. Note that this can get quite long. + 'k' This is essentially the same as in 'f' flag - it will display the + full hierarchy of the tag, and additionally will provide the + information of the kind of the tag. For example, if you put the following into your statusline: > %{tagbar#currenttag('[%s] ','')}