xavierd / clang_complete

Vim plugin that use clang for completing C/C++ code.
http://www.vim.org/scripts/script.php?script_id=3302
1.95k stars 308 forks source link

Troubleshooting - omnifunc and completefunc are not set to ClangComplete. What now? #591

Closed SanJacobs closed 2 years ago

SanJacobs commented 2 years ago

It seems to me that the completions I get when hitting Ctrl+N are way too bad to actually be the work of clang_complete.

For installation, I've tried installing with a plugin manager, cloning the repository into ~/.vim/clang_complete and tried putting the entire contents of the repository into ~/.vim/.

Doing set omnifunc? completefunc? returns:

omnifunc=ccomplete#Complete
completefunc=

Great. It didn't work. What now? What does this mean?

:messages doesn't return anything at all.

xaizek commented 2 years ago

Are you using Vim and not neovim, which uses different configuration location?

SanJacobs commented 2 years ago

@xaizek I am using neovim

xaizek commented 2 years ago

Then you probably need to use ~/.config/nvim directory.

SanJacobs commented 2 years ago

@xaizek Thanks for the suggestion. I tried that, and in the process also tried using regular vim and the regular install directory, but sadly, neither made any difference.

xaizek commented 2 years ago

Maybe something is wrong with your setup then. set runtimepath? should print paths Vim/nvim looks at. You can also try running :scriptnames to see the list of loaded files, where they are located and whether clang_complete shows up in there. Also you can post tree ~/.vim and tree ~/.config/nvim here, maybe you're doing something wrong with files.

SanJacobs commented 2 years ago
runtimepath=~/.vim,~/.vim/plugged/csound-vim,~/.vim/plugged/vim-ragtag,~/.vim/plugged/vim-surround,~/.vim/plugged/vim-fugitive,~/.vim/plugged/vim-airline,~/.vim/plugged/vim-airline-themes,~/.vim/plugged/undotree,~/.vim/plugged/gruvbox,~/.vim/plugged/vim-one,~/.vim/plugged/vim-signify,~/.vim/plugged/ale,~/.vim/plugged/vim-rainbow,~/.vim/plugged/vimwiki,~/.vim/plugged/ctrlp.vim,~/.vim/plugged/vim-svelte,~/.config/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/share/xfce4/nvim/site,~/.local/share/flatpak/exports/share/nvim/site,/var/lib/flatpak/exports/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/share/nvim/site,/usr/share/nvim/runtime,/usr/share/nvim/runtime/pack/dist/opt/matchit,/usr/share/nvim/site/after,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,/var/lib/flatpak/exports/share/nvim/site/after,~/.local/share/flatpak/exports/share/nvim/site/after,/usr/share/xfce4/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/after,~/.vim/after

When I run :scriptnames, I'm reminded that my .vim folder is a symlink to a .vim folder in a git repo I use for my dotfiles. I tried to replace the symlink with a copy of the actual folder, but it made no difference. set omnifunc? completefunc? still return the same thing in both NeoVim and Vim.

~/.vim/plugin/clang_complete.vim does show up in :scriptnames, though.

tree ~/.vim: tree-of-dotvim.txt

❯ tree ~/.config/nvim
/home/san/.config/nvim
└── init.vim

0 directories, 1 file

❯ cat .config/nvim/init.vim 
    set runtimepath^=~/.vim runtimepath+=~/.vim/after
    let &packpath = &runtimepath
    source ~/.vimrc
SanJacobs commented 2 years ago

I don't know what happened, but while messing with my color schemes, I did source % a ton of times, and one of those times I got this error!

image

Woohoo, it finally loaded!

So I found out that clang and libclang are different things, and the libclang.so file I had, was not really the one I needed for clang_complete. I installed libclang1, and now things seem to be working. set omnifunc? completefunc? Returns ClangComplete. Thanks for the help, despite the solution turned out to be randomly spamming source .vimrc :sweat_smile:

SanJacobs commented 2 years ago

I found a potential actual solution when trying to set up clang_complete on another machine. I had the exact same problem here. It just doesn't tell me what is wrong. The actual problem is the one shown in the screenshot in my previous post, but that doesn't get reported, it seems. (Maybe this is worth a bug report?)

To solve it, make sure, if you've supplied only the directory for libclang.so, that there is actually a file there named EXACTLY libclang.so. libclang.so.1 will not work. I just copied the one named .so.1 and renamed it, and now it works.