Remove need to provide complete jsctags configuration if jsctags not in path

This commit is contained in:
Jan Larres 2011-12-21 20:33:31 +13:00
parent 9a2cf9756f
commit f9b50a1e95
2 changed files with 38 additions and 17 deletions

View File

@ -418,7 +418,8 @@ function! s:InitTypes()
" Alternatively jsctags/doctorjs will be used if available.
let type_javascript = {}
let type_javascript.ctagstype = 'javascript'
if executable('jsctags')
let jsctags = s:CheckFTCtags('jsctags', 'javascript')
if jsctags != ''
let type_javascript.kinds = [
\ {'short' : 'v', 'long' : 'variables', 'fold' : 0},
\ {'short' : 'f', 'long' : 'functions', 'fold' : 0}
@ -431,7 +432,7 @@ function! s:InitTypes()
let type_javascript.scope2kind = {
\ 'namespace' : 'v'
\ }
let type_javascript.ctagsbin = 'jsctags'
let type_javascript.ctagsbin = jsctags
let type_javascript.ctagsargs = '-f -'
else
let type_javascript.kinds = [
@ -785,18 +786,20 @@ function! s:GetUserTypeDefs()
" generate the other one
" Also, transform the 'kind' definitions into dictionary format
for def in values(defdict)
let kinds = def.kinds
let def.kinds = []
for kind in kinds
let kindlist = split(kind, ':')
let kinddict = {'short' : kindlist[0], 'long' : kindlist[1]}
if len(kindlist) == 3
let kinddict.fold = kindlist[2]
else
let kinddict.fold = 0
endif
call add(def.kinds, kinddict)
endfor
if has_key(def, 'kinds')
let kinds = def.kinds
let def.kinds = []
for kind in kinds
let kindlist = split(kind, ':')
let kinddict = {'short' : kindlist[0], 'long' : kindlist[1]}
if len(kindlist) == 3
let kinddict.fold = kindlist[2]
else
let kinddict.fold = 0
endif
call add(def.kinds, kinddict)
endfor
endif
if has_key(def, 'kind2scope') && !has_key(def, 'scope2kind')
let def.scope2kind = {}
@ -972,6 +975,24 @@ function! s:CheckExCtagsVersion(output)
return major >= 6 || (major == 5 && minor >= 5)
endfunction
" s:CheckFTCtags() {{{2
function! s:CheckFTCtags(bin, ftype)
if executable(a:bin)
return a:bin
endif
if exists('g:tagbar_type_' . a:ftype)
execute 'let userdef = ' . 'g:tagbar_type_' . a:ftype
if has_key(userdef, 'ctagsbin')
return userdef.ctagsbin
else
return ''
endif
endif
return ''
endfunction
" Prototypes {{{1
" Base tag {{{2
let s:BaseTag = {}

View File

@ -663,9 +663,9 @@ deffile: The path to a file with additional ctags definitions (see the
ctagsbin: The path to a filetype-specific ctags-compatible program like
{optional} jsctags. Set it in the same way as |g:tagbar_ctags_bin|. jsctags is
used automatically if found in your $PATH and does not have to be
set in that case. If it is not in your path you have to provide the
complete configuration and use the "replace" key (see the
Tagbar source code for the suggested configuration).
set in that case. If it is not in your path you have to set this
key, the rest of the configuration should not be necessary (unless
you want to change something, of course).
ctagsargs: The arguments to be passed to the filetype-specific ctags program
{optional} (without the filename). Make sure you set an option that makes the
program output its data on stdout. Not used for the normal ctags