Does it support different ctags file chosen dynamically?
marcelolima opened this issue · 2 comments
In my setup I'm already using gutentags to automatically create the tags for the repository I'm working on (python), and I have another shortcut for generating the tags just for the libraries (not done automatically since it takes time and would pollute the main app ctags file). Right now I'm trying to set up some new shortcut that would allow me to navigate to the definition using the libraries ctags file instead of the one that was initially passed to g:gutentags_ctags_tagfile
, but can't find a good way. Has anyone done something similar?
Eg:
g] -> use `gutentags_ctags_tagfile` normally
<F12> -> use the lib tagfile
As what I understand, you want to create different tagfiles for different files of one repos.
So, for example, we have cpp
and py
files in a repos. How to create two tags for cpp
and py
respectively?Here is my solution.
let g:gutentags_ctags_tagfile=&filetype.'.ctags' #optional
au BufEnter,BufRead * let g:gutentags_ctags_tagfile=&filetype.'.ctags'
use echo g:gutentags_ctags_tagfile
in vim to check your tagfile name when you open a file or switch between two files.
That's a nice trick @wow-yes thanks.
I think @marcelolima was maybe asking about switching the tagfile used for looking up a symbol? In that case, I think that temporarily setting the tags
variable would work (see :help 'tags'
), but frankly vim does a good job of handling multiple tag files anyway, so setting that variable to both tag files (separated by a space or comma) would let vim search both when typing g]
. Usually gutentags sets that variable automatically but that could mess-up your setup in this case, so you can disable that with g:gutentags_ctags_auto_set_tags
.