I am developing a Linux kernel driver so I have a git directory with my project.
I have another git directory with the Linux sources.
I am using neovim with gutentags with the setting of gtags_cscope as the gutentags_modules.
My cache dir is .cache/vim. gtag-cscope generates different tag directories for each of the projects.
When I edit a file in my driver project and try to jump to the definition of a kernel function I see that the symbol is not found. However if I edit a file in the Linux kernel directory and try to jump to the definition of kernel function the symbol is found.

So it seems that gutentags or gtag-cscope cannot search in multiple tag directories. Is there a way to enable it?


1 Answer 1


Vim is able to query tags from multiple projects and usually all you need to do is set the 'tags' option to point to the tags files in each directory.

In 'nocompatible' mode (which is the default), 'tagrelative' defaults to "on", which means when Vim finds the tag in a tags file in another directory (a tag belonging to the other project), it will look up the file name relative to the directory where that tags file is, rather than the current directory.

So you could also look up tags from the Linux kernel source tree using:

set tags+=/path/to/src/linux/tags

Assuming /path/to/src/linux is the directory where your Linux kernel source tree lives, and that you have successfully created a tags file there. You can do so by changing to that top directory and running ctags -R . (but the exact details might depend on which version of the "ctags" program you have in your system.)

I'm not really sure how plug-ins such as "gutentags" or "gtag-cscope" will interact with these settings. My understanding is that they're mostly concerned with keeping the tags file up to date, by invoking ctags in background after you modify local files, so I think it's quite reasonable that they'll just leave your addition to the 'tags' option alone, so it's quite possible everything will just keep working even in the presence of such plug-ins. So I'd suggest you just go ahead and try it, see if it works, it's likely that it will.

  • It does not help as it only shares the ctags files. I need to share the directories with the GPATH, GRTAGS & GTAGS of the two projects so I can do find all references of a symbol
    – Monti
    Sep 16, 2020 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.