3

I have the omnicppcomplete plugin with exuberant ctags, I generate tags for projects with the following command:

ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .

What I am trying to achieve is to have Vim recognize the type of an object when I access it through an STL container, to provide me with an appropriate list of autocomplete suggestions.

For example suppose the IntWrapper object has a getTheInt() method and I have a vector of IntWrappers:

std::vector<IntWrapper> wrappers;

If I have the following code:

for (size_t i = 0; i < wrappers.size(); i++) {
    wrappers[i].<VIM Cursor is here>
}

I'd like VIM to understand that wrapper[i] is of type IntWrapper and to give me the getTheInt() method as the first autocompletion choice, along with documentation, as if I operated on an IntWrappers object directly.

To make clear what I would expect, the first screenshot below is what happens when I ask for autocompletion on the vector, the second one is what happens when I access the object directly, and what I'd like to achieve even with stl containers.

Expression not found

(The sentence highlighted in red above says expression not found)

Working

Is there any plugin (I don't care about CPU expensiveness) to do this?

Many thanks.

Vincenzo Pii
  • 18,961
  • 8
  • 39
  • 49

1 Answers1

5

Actually, I think that omnicomplete can't deal with context issue, so you can't use it for your purpose. A way to do C++/STL auto-completion is to use clang_complete (or here).

The performance seems to be quite problematic though (Have a look here : How to improve the completion speed of clang_complete? ).

A nice tutorial on the subject (configure vim + clang for C++ STL completion) could be found here : http://zwiener.org/vimautocomplete.html

Ref:

NB : Another option is to use gccsense which is a stand alone tool using GCC's code analyzers. Here is the link to the project homepage : http://cx4a.org/software/gccsense/ and on two SO questions about its use :

Community
  • 1
  • 1
Nic_tfm
  • 440
  • 2
  • 7
  • 2
    `clang_complete` uses the python bindings and there is a lot of work ongoing on them, for anyone planning to use them I suggest keeping close to the trunk version. – Matthieu M. Mar 02 '12 at 09:40