From 2da3443f5fb78aa0b9a60bb5b2926d72df734e14 Mon Sep 17 00:00:00 2001 From: David Hegland Date: Thu, 24 Jun 2021 09:37:26 -0500 Subject: [PATCH] Better handling for typeinfo.deffile (#777) Closes #776 Change the ordering of the --options field when executing ctags. This allows overrides of things like the ---kinds definitions to omit certain kinds. Also add check to ensure the typeinfo.deffile exists before attempting to use it in the ctags arguments. --- autoload/tagbar.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 1da6055..87324e0 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1390,11 +1390,6 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort let ctags_args += [ '-V' ] endif - " Include extra type definitions - if has_key(a:typeinfo, 'deffile') - let ctags_args += ['--options=' . expand(a:typeinfo.deffile)] - endif - " Third-party programs may not necessarily make use of this if has_key(a:typeinfo, 'ctagstype') let ctags_type = a:typeinfo.ctagstype @@ -1409,6 +1404,12 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort let ctags_args += ['--language-force=' . ctags_type] let ctags_args += ['--' . ctags_type . '-kinds=' . ctags_kinds] endif + + " Include extra type definitions - include last to allow for any + " overrides + if has_key(a:typeinfo, 'deffile') && filereadable(expand(a:typeinfo.deffile)) + let ctags_args += ['--options=' . expand(a:typeinfo.deffile)] + endif endif if has_key(a:typeinfo, 'ctagsbin')