3

When I checkout different branches, I sometimes notice that files in the repo are not available to Vim plugins that search based on the ctags index.

I don't have a definitive test that's shown the files are missing due to versioning, but I usually notice that the missing files are those that were recently added.

I occasionally notice other missing lookups, e.g. with function names or other symbols, and assume it's the same matter. I'll quickly provide any details if someone has ideas.

  • 2
    Are you doing the git checkouts and pulls from within Vim? This sounds like something to solve in git, independently of vim. – Gilles 'SO- stop being evil' Feb 21 '15 at 14:19
  • @Gilles I am not - all git changes are happening on my own in bash CLI. But, if any thinks this makes it off-topic, the integration is specific to Vim, and I wasn't positive if the issue was caused by another matter that others have seen commonly – New Alexandria Feb 22 '15 at 4:02
  • Thanks @carpetsmoker, I wanted to add the ctags tag, but didn't have the rep. – New Alexandria Feb 23 '15 at 0:02
6

Depending on how you update your ./tags file:

If you do not commit your ./tags file to your branch/repository you can use a git hook that calls ctags -R . on each pull/checkout you do - this way your ./tags file will always contain data on all present files in the current version you have checked out.

If you do want to commit your ./tags file, you can also save that to a hook on push/commit.

You could teach vim to do that, but this is something git can handle nicely for you.

  • 1
    Tim Pope wrote a blog article a few years back that details how something like this can be done. – tommcdo Feb 22 '15 at 2:55
  • I don't check in the tags file, and I don't have an immediate sense of need to do this. I'd actually never thought of it, and for ludicrously-large projects I can see the benefit. Thanks for the edge case tip! Do you know about those git hooks? Pardon; I'm sure I can find this out one my own, in time. – New Alexandria Feb 22 '15 at 4:03
  • @New Alexandria: if you want to learn more about git hooks, I suggest to check out your .git/hooks folder. By default there should be some example scripts in there to inspire you. For details check out the official documentation at: git-scm.com/book/en/v2/Customizing-Git-Git-Hooks – Rock Feb 22 '15 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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