I have a c project and I would like to use the feature of LSP in Neovim such as gd
(go to definition).
I follow each of these materials to configure LSP
-
Konwing that I need to use clangd.
nvim-lspconfig/doc/server_configurations.md#clangd and clangd.llvm.org/installation
To install clangd on Ubuntu (18.04).
-
To configure nvim-lspconfig, being like
require('lspconfig').clangd.setup{ on_attach = function() print("Hello C/C++!") end }
clangd.llvm.org/installation#project-setup
I use Bear to produce complile_command.json
However, I've encountered some problems.
Following the guide in clangd.llvm.org/installation, I execute
sudo apt-get install clangd-10
to install clangd (sudo apt-get install clangd-12
will result inE: Unable to locate package clangd-12
even though I have executedsudo apt-get update
). But when I want to check the version of clangd by executingclangd --version
, I gotCommand 'clangd' not found
as it is not installed yet.After executing
bear <my_build_command>
, I got the complile_command.json. But when I open .c file in the project, I got the information: Spawning language server with cmd:clangd
failed. The language server is either not installed, missing from PATH, or not executable.
--
I think the problem may result from 1. After Googleing the related information and tried to reinstall clangd, clangd --version
still result in the same: Command 'clangd' not found
.
Do I missing something or what? Any one can give me a help? Thanks.
clangd --version
gives me the version information.