c0r73x / neotags.nvim

Tag highlight in neovim
MIT License
122 stars 9 forks source link

Only update tags matching the buffer saved #12

Closed haasn closed 6 years ago

haasn commented 7 years ago

It seems like neotags.nvim does not work unless neotags itself is in charge of actually generating the tags file. But I don't like the way neoplete generates tags.

The plugin I'm using currently for that, vim-autotag, only updates tags related to the buffer I just saved. So I can manually run ctags to add additional source files, which will not get clobbered by the script. If I try doing the same with neotags, they get removed:

$ ctags -R --extras=+f --fields=\* /usr/include/vulkan .
$ grep -c 'vulkan.h' tags
3736
# save buffer with neotags running
$ grep -c 'vulkan.h' tags
0

It would be great if you could either modify this script to behave more like vim-autotag (thus preserving the existing tags), or alternatively make it possible to combine neotags with vim-autotag somehow (so I can use neoplete for tag highlighting and vim-autotag for tag updating).

c0r73x commented 7 years ago

Hi you can disable the tag generation in neotags by setting g:neotags_run_ctags to 0.

Not sure about --fields=* does but you need to have --fields=+l for neotags because it checks the language when reading the tagfile.

haasn commented 6 years ago

Hi you can disable the tag generation in neotags by setting g:neotags_run_ctags to 0.

If I set this, neotags does not seem to do anything. (No highlighting, etc.)

Edit: Scratch that, I tested it again and it seems to work; as long as I generate the ctags correctly. Not entirely sure why it was not working the other time I tested it.

haasn commented 6 years ago

After some further investigation, I figured out where my issues were coming from:

  1. For some reason, neotags will only accept a tags file in the current directory (static path ./tags); rather than going up recursively to accept a tags file in a parent directory like vim itself does. This caused me some amount of confusion; since I normally have a single top-level tags file in the project root; whereas neotags will have happily dumped tags files into the individual subdirectories of my project. These left-over tags files were what made it appear to sometimes work and sometimes not.

  2. For some reason, the ctags fields KnzZ break the functioning of neotags. Using ctags --fields=\*-KnzZ to exclude these non-working fields restores the functionality of neotags even with externally generated tags files.