1
0
mirror of https://github.com/gryf/tagbar.git synced 2026-03-08 02:26:03 +01:00

Add tag datatype (#698)

Closes #680

Add `g:tagbar_show_data_type` field to show the tag datatype next to the tag in the tagbar window
This uses the `--fields=t` field to get the datatype from ctags. If not found, then it will attempt to derive the datatype by extracting all the output from the `pattern` preceeding the tag name.

More testing is needed on other languages. So far this has been stable with C / C++ files parsing the datatype from ctags output. It has also been tested with Java files for the inferred datatype by parsing the pattern line and pulling out everything prior to the tag.
This commit is contained in:
raven42
2020-11-02 15:06:40 -06:00
committed by GitHub
parent 99c22f1bb2
commit 601b5c0073
5 changed files with 73 additions and 2 deletions

View File

@@ -1342,7 +1342,7 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort
\ '-',
\ '--format=2',
\ '--excmd=pattern',
\ '--fields=nksSaf',
\ '--fields=nksSaft',
\ '--sort=no',
\ '--append=no'
\ ]
@@ -1541,6 +1541,17 @@ function! s:ProcessTag(name, filename, pattern, fields, is_split, typeinfo, file
let a:fileinfo.fline[taginfo.fields.line] = taginfo
if has_key(taginfo.fields, 'typeref')
let typeref = taginfo.fields.typeref
let delimit = stridx(typeref, ':')
let key = strpart(typeref, 0, delimit)
if key ==# 'typename'
let taginfo.data_type = substitute(strpart(typeref, delimit + 1), '\t', '', 'g')
else
let taginfo.data_type = key
endif
endif
" If this filetype doesn't have any scope information then we can stop
" here after adding the tag to the list
if !has_key(a:typeinfo, 'scope2kind')