vim-gutentags icon indicating copy to clipboard operation
vim-gutentags copied to clipboard

File location mangled when using custom tags file location

Open threewordphrase opened this issue 7 years ago • 2 comments

I am using let g:gutentags_ctags_tagfile='.git/tags'. I want to keep the tags file out of version control and I would like to not have to add it to my .gitignore.

When I try to jump to definition I get this error: "File .git/correct/path/to/file" does not exist". The tags entries are incorrectly prepending .git.

Is there a setting to fix this incorrect prefixing of file paths?

threewordphrase avatar Jan 25 '18 02:01 threewordphrase

As a workaround you could setup a global gitignore file to exclude the tag files of all your projects.

IngoMeyer441 avatar Feb 13 '18 22:02 IngoMeyer441

Various ctags executables have weird and convoluted ways to choose whether they generate the tags file with absolute paths, relative-to-the-tags-file paths, or relative-to-the-current-working-dir paths. This is not something Gutentags can directly figure out.

If you were to set the tagfile path as an absolute path (/path/to/your/project/.git/tags) there's a 90% chance (depending on which ctags executable you use) that it would do what you want (kinda) in the sense that it would use absolute paths to your source code files. You might have to mess around with BufReadPost-type autocommands to set the b:gutentags_ctags_tagfile variable (buffer local... note the b:) to do this however. A nice thing to avoid this would be to add a simple way to use the project root in the value of that setting, like %project_root%/.git/tags, but that would need to be implemented in Gutentags..

Note that if you want your tags files out of your projects, see g:gutentags_cache_dir. Otherwise, @IngoHeimbach's recommendation is also very correct -- and has the nice side-effect that you get project-root-relative paths in your tags as opposed to absolute paths.

ludovicchabant avatar Mar 04 '18 08:03 ludovicchabant