Closed trebinor closed 4 years ago
You need to open C/C++ files to run :CocCommand clangd.install
.
I had the same issue, but then it displays the following message and does nothing else
[coc.nvim] clangd was not found on your PATH. :CocCommand clangd.install will install 10.0.0.
Did you check if it downloaded clangd? It downloaded for me, and I think you're supposed to add the clangd path to your PATH and restart vim. I gave up before I could get it working, because CentOS 7 won't run clangd 10 due to its glibc being too old. I'd happily try an older release without that requirement, but 10.0 seems to be only release posted, not counting pre-releases.
Had same issue and updating my env variable PATH including the clangd fixed for me.
export PATH=$PATH:/home/rodhash/.config/coc/extensions/coc-clangd-data/install/10.0.0/clangd_10.0.0/bin
Also had to manually add the installation directory to my PATH. Not sure if this is intended behavior? If so, perhaps we should add it to the readme?
MWE for newbies (like me):
create Node project
dir01="$HOME/cocnvim_c"
mkdir $dir01 && cd $dir01
npm init # all default
npm i coc-clangd
Add $PATH
cd $HOME/.config/coc/extensions/coc-clangd-data/install/*/clang*/bin && echo $PWD && cd - # copy echo
vim ~/.bashrc # add line: export PATH=$PATH:[paste echo]
test it:
python3.8 -c "print('$PATH'.replace(':','\n'))" | grep -E 'coc|$' # check it
vim $dir01/main.c
Amend alternative to create a Node project (step 1 of my previous comment):
sudo npm i --global coc-clangd
I came up with the same problem, but I figured out why, just run :CocConfig, and it opens the config file: coc-settings.json, add clangd.path
as folllows:
{
"clangd.path": "/usr/local/opt/llvm/bin/clangd"
}
or if you installed clangd as coc suggests(:CocCommand clangd.install), the path should be something like this:
$HOME/.config/coc/extensions/coc-clangd-data/install/*/clang*/bin/clangd
make sure clangd is included in the path
as you can see, I use llvm, which already includes clangd, so I do not need to install clangd suggested by coc
Btw: if C/C++ file is NOT Vim-opened through terminal, the ~/.profile
should have proper $PATH
too: shell configuration files (like ~/.bashrc or /etc/profile) affect only the applications started from shell.
I'm following the "Quick Start" guide and have run into problems on the
:CocCommand clangd.install
step. The guide claimscoc-clangd
will try to findclangd
in my$PATH
. I know thatclangd
is not in my$PATH
, but I see no output from:CocInstall coc-clangd
that it looked and failed to find it. I only see a single line with a green check that it installed into.config/coc/extensions/node_modules/coc-clangd
.When I run
:CocCommand clangd.install
to have it fetch the latest release, it returns[coc.nvim] Command: clangd.install not found
.