3

I would like to know how to generate ctags and find them with auto-complete plugins for new libraries that I install in order to 1) auto-complete for 3rd party library namespaces, classes, etc. and 2) not have my syntax checking plugin think I have undefined references. In order to generate tags for my own new projects, I use this command:

map <C-F12> :!ctags -R --sort=yes --c++-kinds=+pl --fields=+iaSl --extra=+q .<CR>

But how do I adapt this to new libraries in my system? I have tried going to a library's include directory, run the above command, and then set the ctag path to find the tags file, e.g.

:set tags+=/usr/include/pcl-1.7/pcl/tags

But then it seems that the tags are not found. I use the YouCompleteMe and I have the collect_identifiers parameter set:

let g:ycm_collect_identifiers_from_tags_files = 1

How can I enable ctags to find them? I can using Exuberant Ctags 5.9 and VIM 7.4.

5

You could use this to tell Vim to look recursively for tags files under /usr/include/:

set tags+=/usr/include/**/tags

For the generation part, I'm afraid you will still have to generate tags files manually for each new library… or write a shell script.


By the way, Vim comes with what it calls "include-search"; you will probably find the following help sections interesting:

:help include-search
:help definition-search
:help 'include'
:help 'define'
  • I added that to my .vimrc and didn't see a change. I also tried to start vim, enter ":set tags=/usr/include/***/tags" and ":set tags=/usr/include/pcl-1.7/pcl/tags". Neither of those worked. I also changed the owner to my username since those tags are in /usr and I might need sudo to access them. I did ":echo tagfiles()" and I see the path to the library tag file, but still I can't auto-complete and I get undefined reference errors in Syntastic. I tried to add the path to a tag file in my /opt directory and that worked fine. Any ideas for why that would happen? – Sterling Dec 7 '15 at 18:39
  • I am accepting the answer even though my problem still exists because I think my problem is not normal. As I said in my previous comment, when I did this for another library it worked fine so this would be the normal way of doing things. – Sterling Dec 9 '15 at 15:49

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.