feat(gotags): override ctags for go if gotags is installed

This commit is contained in:
John Castronuovo 2020-01-03 23:48:19 +01:00
parent 524aa93372
commit 0a8a22e34d
No known key found for this signature in database
GPG Key ID: AEB5B072A7896F69

View File

@ -147,6 +147,39 @@ function! s:InitTypes() abort
let s:known_types.javascript = type_javascript
endif
" Use gotags if available
let gotags = s:CheckFTCtags('gotags', 'go')
if gotags !=# ''
call tagbar#debug#log('Detected gotags, overriding typedef')
let type_go = tagbar#prototypes#typeinfo#new()
let type_go.ctagstype = 'go'
let type_go.kinds = [
\ {'short' : 'p', 'long' : 'package', 'fold' : 0, 'stl' : 0},
\ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0},
\ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0},
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0},
\ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 0},
\ {'short' : 'n', 'long' : 'intefaces', 'fold' : 0, 'stl' : 0},
\ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 0},
\ {'short' : 'r', 'long' : 'constructors', 'fold' : 0, 'stl' : 0},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 0},
\ ]
let type_go.sro = '.'
let type_go.kind2scope = {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ }
let type_go.scope2kind = {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ }
let type_go.ctagsbin = gotags
let type_go.ctagsargs = '-sort -silent'
let type_go.ftype = 'go'
call type_go.createKinddict()
let s:known_types.go = type_go
endif
call s:LoadUserTypeDefs()
" Add an 'unknown' kind to the types for pseudotags that we can't