I was following this link: http://www.ros.org/wiki/IDEs to get my code completion working. On top of the plugin rosvim.vim installed, I also have OmniCppComplete. I don't get the code completion working under ROS, how should I do that? By the way, code completion for any other codes excluding ROS-related codes are just working out of the box.
How should I tailor my ~/.vimrc file. Anyway. I've tried to add yours with the existing one like below:
*I've uninstalled and reinstalled the autocompletion with both methods below but still does not work
To use OmniCppComplete with ROS, you have to generate a set of tags for the ROS stacks. There are probably better ways of doing this, but I was successful with find and grep.
First, generate a list of files that you want to generate tags from:
find /opt/ros/diamondback/stacks | grep -E '*/include/*/.*\.(h|hpp)' > /tmp/ros.filelist
Then use ctags to generate a tags database from this list:
ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -f /tmp/ros.tags -L /tmp/ros.filelist
Once you have done this, you can move your tags file into your ~/.vim directory
mv /tmp/ros.filelist ~/.vim/tags/ros
And edit your ~/.vimrc file accordingly
set tags+=~/.vim/tags/ros " OmniCppComplete settings to be tweaked let OmniCpp_NamespaceSearch=1 let OmniCpp_GlobalScopeSearch=1 let OmniCpp_ShowAccess=1 let OmniCpp_MayCompleteDot=1 let OmniCpp_MayCompleteArrow=1 let OmniCpp_MayCompleteScope=1 let OmniCpp_DefaultNamespaces=["std","_GLIBCXX_STD"] " Hotkey to generate tags for you current project map <F5> :!/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
Hope this helps.
The following .vimrc snippet is mostly from here. Visit the link to see how to create stl, qt, sdl and qt4 tags (or deactivate the "set"-lines).
The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of the ros package in which you are editing files for the ctags command (this assumes the current working dir of vim is your projects directory, see below, which btw also allows you to use :mak). With this, hitting F11 will generate completion tags for your current file's project.
In contrast to the solution of mjcarroll this creates a tagfile in your project's directory, which is specific to the dependencies of your project. Therefore you need to create the tags (F11) for each of the packages in which you are editing files. On the other hand vim should be faster looking up its tag database.
map <f12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<cr> "This is to tag the include for ros packages the current project depends on map <f11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<cr> "map <f11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<cr> " configure tags - add additional tags here or comment out not-used ones set tags+=~/.vim/tags/stdlibtags set tags+=~/.vim/tags/gltags "set tags+=~/.vim/tags/sdl set tags+=~/.vim/tags/qt4tags " OmniCppComplete let OmniCpp_NamespaceSearch = 1 let OmniCpp_GlobalScopeSearch = 1 let OmniCpp_ShowAccess = 1 let OmniCpp_MayCompleteDot = 1 let OmniCpp_MayCompleteArrow = 1 let OmniCpp_MayCompleteScope = 1 "let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] " automatically open and close the popup menu / preview window au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif set completeopt=menuone,menu,preview ",longest "END Omnicompletion
Vim's present working dir (:pwd) needs to be the root directory of your package (i.e., the output of
rospack find <yourpackage>) because calling "rospack cflags-only-I" without package name argument will use the current dir as package name. This is the case if you start vim in that directory or use :cd to change there. Alternatively you could somehow (I do not know how, though) find out the package name of the project your file belongs to, to give it to the rospack call.
Asked: 2011-03-24 13:59:13 -0500
Seen: 837 times
Last updated: Apr 07 '11