From 07f8b5bba57a220a6aa47e5ce503b2dc07a45fec Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 5 Apr 2022 15:25:20 +0800 Subject: [PATCH] feat(gtags): add `ctags_bin` option --- autoload/SpaceVim/layers/gtags.vim | 6 +++++- bundle/gtags.vim/autoload/ctags.vim | 19 ++++++++++++------- bundle/gtags.vim/plugin/gtags.vim | 1 - doc/SpaceVim.txt | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/autoload/SpaceVim/layers/gtags.vim b/autoload/SpaceVim/layers/gtags.vim index c614310ae..c779ba209 100644 --- a/autoload/SpaceVim/layers/gtags.vim +++ b/autoload/SpaceVim/layers/gtags.vim @@ -30,6 +30,7 @@ scriptencoding utf-8 " adding entries. same as |g:gtags_open_list| " 3. `gtagslabel`: the backend of gtags command, you can use `ctags` or " `pygments`. It is empty string by default. +" 4. `ctags_bin`: set the command or path of ctags, default is 'ctags' if exists('s:gtagslabel') finish @@ -87,6 +88,9 @@ function! SpaceVim#layers#gtags#set_variable(var) abort let g:gtags_open_list = get(a:var, \ 'open_quickfix', \ g:gtags_open_list) + let g:gtags_ctags_bin = get(a:var, + \ 'ctags_bin', + \ 'ctags') endfunction function! SpaceVim#layers#gtags#health() abort @@ -97,7 +101,7 @@ endfunction function! SpaceVim#layers#gtags#get_options() abort - return ['gtagslabel'] + return ['gtagslabel', 'ctags_bin'] endfunction diff --git a/bundle/gtags.vim/autoload/ctags.vim b/bundle/gtags.vim/autoload/ctags.vim index 96f717520..e0bf53b5d 100644 --- a/bundle/gtags.vim/autoload/ctags.vim +++ b/bundle/gtags.vim/autoload/ctags.vim @@ -8,14 +8,19 @@ scriptencoding utf-8 -let s:LOGGER =SpaceVim#logger#derive('ctags') - -if !executable('ctags') - call s:LOGGER.warn('ctags is not executable, you need to install ctags') +if exists('g:loaded_ctags') finish endif -if exists('g:loaded_ctags') + +let s:LOGGER =SpaceVim#logger#derive('ctags') + +if !exists('g:gtags_ctags_bin') + let g:gtags_ctags_bin = 'ctags' +endif + +if !executable(g:gtags_ctags_bin) + call s:LOGGER.warn(g:gtags_ctags_bin . ' is not executable, you need to install ctags') finish endif @@ -45,7 +50,7 @@ endfunction function! ctags#update(...) abort if !s:version_checked - call s:JOB.start(['ctags', '--version'], { + call s:JOB.start([g:gtags_ctags_bin, '--version'], { \ 'on_stdout': funcref('s:version_std_out'), \ 'on_exit': funcref('s:version_exit'), \ }) @@ -55,7 +60,7 @@ function! ctags#update(...) abort 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'] + let cmd = [g:gtags_ctags_bin] if s:is_u_ctags let cmd += ['-G'] endif diff --git a/bundle/gtags.vim/plugin/gtags.vim b/bundle/gtags.vim/plugin/gtags.vim index 2f2a536e0..236339c4b 100644 --- a/bundle/gtags.vim/plugin/gtags.vim +++ b/bundle/gtags.vim/plugin/gtags.vim @@ -16,7 +16,6 @@ if !exists('g:gtags_silent') let g:gtags_silent = 1 endif - "" " General form of Gtags command is as follows: " > diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 52e23e1fc..1d4a28b0e 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -2057,6 +2057,7 @@ The layer option can be used when loading the `gtags` layer, for example: adding entries. same as |g:gtags_open_list| 3. `gtagslabel`: the backend of gtags command, you can use `ctags` or `pygments`. It is empty string by default. + 4. `ctags_bin`: set the command or path of ctags, default is 'ctags' ============================================================================== INCSEARCH *SpaceVim-layers-incsearch*