-
Notifications
You must be signed in to change notification settings - Fork 2
LSP.md
Neovim's LSP support is powerful and flexible, and this guide will help you get started with setting up LSPs in your environment. Below are the steps to install, configure, and troubleshoot LSPs.
-
Install an LSP: While editing a file, use the command:
:LspInstall
This will install the appropriate LSP for the current file type.
-
List available LSPs: You can see a list of available LSPs using:
:Mason
For C and C++ development, the configuration uses the clangd
language server. However, clangd
requires a compile_commands.json
file to function properly.
The compile_commands.json
file helps clangd
index your project correctly. If this file is missing, you might encounter errors related to header files or other project components. Follow the steps below to generate it:
-
Using Bear:
- Install Bear using your package manager (e.g.,
apt
,brew
, orpacman
). - Prepend your build command with
bear
. For example:bear -- make
- Install Bear using your package manager (e.g.,
-
Using compiledb:
- Install
compiledb
using your package manager. - Run your build command with
compiledb
. For example:compiledb make
- Install
- If your
make
process fails, Bear will not generate thecompile_commands.json
file, as it depends on a successful build. - Ensure that your build system and
compile_commands.json
file are properly set up to allowclangd
to recognize your project's structure.
Once the compile_commands.json
file is generated and placed in the root directory of your project, clangd
will index your project without issues.