From df960e8b9cd4a96dda76278fc798b826dea29862 Mon Sep 17 00:00:00 2001 From: Michael Goerz Date: Sat, 3 Feb 2018 17:54:44 -0500 Subject: [PATCH 1/2] Add g:tagbar_ctags_options --- autoload/tagbar.vim | 4 ++++ doc/tagbar.txt | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 4d5a1f1..00d3996 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1096,6 +1096,10 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort \ '--sort=no', \ '--append=no' \ ] + if exists('g:tagbar_ctags_options') + let ctags_args = add(ctags_args, + \ '--options='.g:tagbar_ctags_options) + fi " verbose if debug enabled if tagbar#debug#enabled() diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 0efcf37..a995e2d 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -390,6 +390,22 @@ Example: let g:tagbar_ctags_bin = 'C:\Ctags5.8\ctags.exe' < + *g:tagbar_ctags_options* +g:tagbar_ctags_options +Default: undefined + +Use this option to specify the '--options' flag for the ctags executable, +reading in an additional ctags configuration file. This is similar to the +deffile key for tagbar type extensions, see |tagbar-extend|, but acts +globally. + +Example: +> + let g:tagbar_ctags_options = split(&rtp,",")[0].'/ctags.cnf' + +This makes sure that ctags is called with options from ~/.vim/ctags.cnf + + *g:tagbar_left* g:tagbar_left~ Default: 0 @@ -1269,7 +1285,9 @@ ctags manually execute the following command in a terminal: ctags -f - --format=2 --excmd=pattern --extra= --fields=nksaSmt myfile < If you set the |g:tagbar_ctags_bin| variable you probably have to use the same -value here instead of simply "ctags". +value here instead of simply "ctags". Also, if you use +|:tagbar_ctags_options|, you should include the equivalent --options flag in +the call to ctags. If something more fundamental isn't working right then try running the |:messages| command to see if Tagbar printed any error messages that might From 9c60e7f6c61eac69320624144be3a75c179c98a5 Mon Sep 17 00:00:00 2001 From: Michael Goerz Date: Sat, 3 Feb 2018 20:14:37 -0500 Subject: [PATCH 2/2] Accept a list, allowing 'NONE' to avoid duplicates --- autoload/tagbar.vim | 13 ++++++++----- doc/tagbar.txt | 16 ++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 00d3996..ba19530 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1086,7 +1086,14 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort "intended to be in an argument, spaces in a single ctag_args "string would be ambiguous. Is the space an argument separator "or to be included in the argument - let ctags_args = [ '-f', + let ctags_args = [] + if exists('g:tagbar_ctags_options') + for value in g:tagbar_ctags_options + call add(ctags_args, '--options='.value) + endfor + fi + let ctags_args = ctags_args + [ + \ '-f', \ '-', \ '--format=2', \ '--excmd=pattern', @@ -1096,10 +1103,6 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort \ '--sort=no', \ '--append=no' \ ] - if exists('g:tagbar_ctags_options') - let ctags_args = add(ctags_args, - \ '--options='.g:tagbar_ctags_options) - fi " verbose if debug enabled if tagbar#debug#enabled() diff --git a/doc/tagbar.txt b/doc/tagbar.txt index a995e2d..7a98fd5 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -394,16 +394,20 @@ Example: g:tagbar_ctags_options Default: undefined -Use this option to specify the '--options' flag for the ctags executable, -reading in an additional ctags configuration file. This is similar to the -deffile key for tagbar type extensions, see |tagbar-extend|, but acts -globally. +Use this option to specify a list of filenames to pass to ctags with the +'--options' flag. This is similar to the deffile key for tagbar type +extensions, see |tagbar-extend|, but acts globally. The special value 'NONE' +as the first entry disables reading of the default configuration files (e.g. +~/.ctags). Without this, if ~/.ctags and other files listed in +g:tagbar_ctags_options include some of the same patterns, tagbar might show +duplicate entries. Example: > - let g:tagbar_ctags_options = split(&rtp,",")[0].'/ctags.cnf' + let g:tagbar_ctags_options = ['NONE', split(&rtp,",")[0].'/ctags.cnf'] -This makes sure that ctags is called with options from ~/.vim/ctags.cnf +This causes ctags to use settings from ~/.vim/ctags.cnf, ignoring other +configuration files. *g:tagbar_left*