clangd / coc-clangd

clangd extension for coc.nvim
Apache License 2.0
762 stars 34 forks source link

:CocCommand clangd.install #61

Closed trebinor closed 4 years ago

trebinor commented 4 years ago

I'm following the "Quick Start" guide and have run into problems on the :CocCommand clangd.install step. The guide claims coc-clangd will try to find clangd in my $PATH. I know that clangd 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.

fannheyward commented 4 years ago

You need to open C/C++ files to run :CocCommand clangd.install.

Roulbac commented 4 years ago

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.
trebinor commented 4 years ago

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.

rodhash commented 4 years ago

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

xrisk commented 3 years ago

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?

juanMarinero commented 3 years ago

MWE for newbies (like me):

  1. create Node project

    dir01="$HOME/cocnvim_c"
    mkdir $dir01 && cd $dir01
    npm init # all default
    npm i coc-clangd
  2. 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]
  3. test it:

    python3.8 -c "print('$PATH'.replace(':','\n'))" | grep -E 'coc|$'  # check it
    vim $dir01/main.c
juanMarinero commented 3 years ago

Amend alternative to create a Node project (step 1 of my previous comment): sudo npm i --global coc-clangd

CengsBlanky commented 3 years ago

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

juanMarinero commented 3 years ago

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.