shawncplus/phpcomplete.vim

How to generate ctags?

gabesullice opened this issue · 4 comments

Just getting started and I think I'm missing some steps.

I don't think that I'm generating tags properly. I've installed phpctags and it's in my $PATH, but I'm sure I probably need to tell phpcomplete.vim about it somehow in my .vimrc. Is that the case?

Thanks for your hard work!

It sounds like you are only need to generate the tags file itself. This plugin itself doesn't execute the tag-generation on it's own, so in case of phpctags:

  1. Open up a terminal
  2. Navigate to the root folder (the one you usually use as vim's cwd)
  3. Execute phpctags (given it's in your $PATH)

You should en up with a file named tags in the same folder. Vim should automatically find this one if you open vim in the same folder (i'm oversimplifying things here, see the tags option) and as long as vim sees it, the plugin will try to make use of it when you hit ctrl+xctrl+o

Let me know if it worked or not.

(Sidenote: I really should sit down and do a documentation page for this already 😅 )

Ah, I was under the impression that it was supposed to be automatic.

I had to run phpctags --memory=-1 -R to get a file to be generated (I found this somewhere online).

I know it's not specific to your plugin, but I really appreciate the help. Does that command need to be run whenever changes are made? Is there something you use to keep it up to date?

There are a number of plugins to manage your tags. Unfortunately I've no personal experience with any of these, I usually just execute the generation from inside vim (just by executing :!ctags ...), anyway here's a few I've heard of before (in no particular order):

https://github.com/craigemery/vim-autotag
https://github.com/xolox/vim-easytags
https://github.com/ludovicchabant/vim-gutentags (👍 for the name)
https://github.com/jespino/vim-rebtags
https://github.com/luchermitte/lh-tags

I'd advise against regenerating tag files on every save or file-change because the plugin tries to cache results as much as possible and uses the tag file's mtime to invalidate those caches (maybe doing it on git commits with a hook in the repo could be a nice balance of freshness and speed).

@gabesullice: Thank you very much for the GUIDE.md, I greatly appreciate it.

I've took the liberty to edit the section about the tags option since the default value usually is enough and you rarely need to touch it (if ever).