Question

I just installed omnicppcomplete and it is "kindof" working.

The behaviour is realy strange, Omnicppcomplete is working for some files but not for others.

E.g.: If I open file1.cpp omnicppcomplete is working if I push . However, if I open file2.cpp omnicppcomplete is not working anymore and I get the error: -- Omni complete (^O^N^P) Pattern not found.

Here is my complete .vimrc:

" -------------------------------- PLUGINS ----------------------------"
"############### ctags

" build tags of your own project
map <C-c> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR>

"############### OmniCppComplete
au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main
filetype on

" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/cpp
set tags+=~/.vim/tags/cuda

let OmniCpp_NamespaceSearch = 1
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"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview

Furthermore, I'm using MacVim 7.3.

Any help is much appreciated.

Was it helpful?

Solution

First thing: I would recommend you not to deal with ctags manually, but use plugin Indexer instead, it will do all the work automatically. I used Indexer and omnicppcomplete for a long time, in most cases omnicppcomplete works acceptably.

For detailed information, see my article: Vim: convenient code navigation for your projects, which explains the usage of Indexer + Vimprj thoroughly.

Second thing: Omnicppcomplete works acceptably, but not perfect. For C/C++ autocompletion I would recommend you not to use omnicppcomplete, but use clang_complete plugin instead. It is really powerful, completion is done not by ugly tags method, but with real C/C++/Objective-C compiler (which is clang).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top