2

I'm trying to use omnicppcomplete in VIM and I can't get it to work for variables passed to a function. For example, typing the following

function1( MyObject obj ) {
    obj.|
}

results in "--Omni completion (^O^N^P) Pattern not found"

If I define a local variable within the function:

function1 ( MyClass obj) {
    MyClass obj2;
    obj2.|
}

it works fine and I get a popup list of the members. It also works well for global objects but does not seem to be able to determine what the variable is when it is passed as a function parameter.

My .vimrc contains:

set tags+=~/.vim/tags/cpp
set tags+=~/Projects/myproject/Software/tags

" OmniCppComplete
let OmniCpp_NamespaceSearch = 2
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
let OmniCpp_LocalSearchDecl = 1 " use local search function, bracket on 1st column
let OmniCpp_DisplayMode = 1 
au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview


map <F8> :!/usr/bin/ctags -R --exclude=backups --language-force=C++ --sort=yes -c++-kinds=+pl --fields=+iaS --extra=+q -f ~/Software/tags ~/Software .<cr>
2
  • Works perfectly here, with your exact OmniCpp options. You use MyObject in one case and MyClass in the other, perhaps this is the error? Aug 21, 2011 at 6:00
  • I don't see any settings in here to regenerate the tags in ~/Projects/myproject/Software/tags Are those dated, by chance? Aug 21, 2011 at 7:08

1 Answer 1

0

Unfortunately, omnicppcomplete relies on ctags which is not really efficient regarding C++ understanding.

You should have a look at clang_complete. It's likely to give better results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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