Clangd Config CMakeLists. txt
Dionysen

Vim using Coc-nvim plugin clangd-lsp need to read CMakeLists.txt so that it can auto-complete your code.
If your project builds with CMake, it can generate this file. You should enable it with:

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

Or add to CMakeLists.txt:

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

compile_commands.json will be written to your build directory. If your build directory is $SRC or $SRC/build, clangd will find it. Otherwise, symlink or copy it to $SRC, the root of your source tree.

ln -s ~/myproject-build/compile_commands.json ~/myproject/

Generated compile_commands.json can support auto completion for third party libraries.

显示评论