Clangd for Neovim

Clangd is a language server for C, and C++.

Clangd Lsp Configuration

Clangd is configured with a configuration file at the root of your project. There are two options either a compile_commands.json or compile_flags.txt.

compile_flags.txt

This is the most straight forward option. Simply list the flags you pass to the compiler, one flag per link. To use c++ version 20, you would simply add this line to your compile_flags.txt:

-std=c++20

compile_commands.json

If your setup is more complicated, a compile_flags.json file can be generated with cmake. To generate this file provide the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON flag to cmake.

To regenerate this every time you run cmake, add this line to your CMakeLists.txt file:

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)