1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:20:04 +08:00

feat(ctags): use -G option when generate tags

ref: https://github.com/SpaceVim/SpaceVim/issues/4619
This commit is contained in:
wsdjeg 2022-04-05 12:19:26 +08:00
parent 2288bf7db2
commit fd8cffda09

View File

@ -24,12 +24,41 @@ let s:FILE = SpaceVim#api#import('file')
let g:loaded_ctags = 1
function! ctags#update() abort
let s:is_u_ctags = 0
let s:version_checked = 0
function! s:version_std_out(id, data, event) abort
for line in a:data
if line =~# 'Universal Ctags'
let s:is_u_ctags = 1
break
endif
endfor
endfunction
function! s:version_exit(id, data, event) abort
if a:data ==# 0
let s:version_checked = 1
call ctags#update()
endif
endfunction
function! ctags#update(...) abort
if !s:version_checked
call s:JOB.start(['ctags', '--version'], {
\ 'on_stdout': funcref('s:version_std_out'),
\ 'on_exit': funcref('s:version_exit'),
\ })
return
endif
let project_root = getcwd()
call s:LOGGER.info('update ctags database for ' . project_root)
let dir = s:FILE.unify_path(g:tags_cache_dir)
\ . s:FILE.path_to_fname(project_root)
let cmd = ['ctags']
if s:is_u_ctags
let cmd += ['-G']
endif
if !isdirectory(dir)
call mkdir(dir, 'p')
endif