Search code examples
c++vimautocompletevim-pluginomnicomplete

OmniCppComplete in Vim available only as root


I tried to install OmniCppComplete in Vim and I followed this tutorial: http://en.kioskea.net/faq/2367-the-autocompletion-c-c-in-vim

I noticed that the plugin works only if I am as a root. Could anyone give me a tip how to make this plugin available for all users?

.Vimrc: (from tutorial)

set nocp      
filetype plugin on      

set tags+=~/.vim/tags/stl      
set tags+=~/.vim/tags/gl      
set tags+=~/.vim/tags/sdl      
set tags+=~/.vim/tags/qt4      


noremap <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>      
inoremap <F12> <Esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>      

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"]      

au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif      
set completeopt=menuone,menu,longest,preview

I'll be very glad for all hints and answers! Greetings,


Solution

  • I found the solution (according to comment from romainl, thanks!). I have repeated the same process for non-root user.

    I needed to modified my .vimrc a bit:

    syntax on
    filetype plugin on
    
    set tags+=/home/USER_NAME/.vim/tags/stl/tags
    set tags+=/home/USER_NAME/.vim/tags/gl/tags
    set tags+=/home/USER_NAME/.vim/tags/sdl/tags
    
    noremap <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
    inoremap <F12> <Esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
    
    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"]
    
    au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
    set completeopt=menuone,menu,longest,preview
    

    First, I have repleaced

    set tags+=~/.vim/tags/stl
    

    with:

    set tags+=/home/USER_NAME/.vim/tags/stl
    

    Second, I needed to pointed "tags" file directly, so:

    set tags+=/home/USER_NAME/.vim/tags/stl/tags
    

    Other ways, It provides OmniCpp pattern not found. More info for example here: vim omnicppcomplete pattern not found

    I hope it will be helpful for the others:) Greetings and thanks for help. Now it works fine for non-root user as well.