clangd fails to index code on project built on local environment
Affected version
- Nightly flatpak: No (Because clangd is not active)
- Other: V44.2 on Gentoo
Steps to reproduce
- Activate the clangd lsp plugin
- Clone the repository https://gitlab.gnome.org/ilhooq/book-up.git
- Configure the project to build on the local host and inside the source tree
- Build the project
Current behavior
The project is built inside the _build directory.
When we open a source file, for instance main.c, there is multiple errors generated by clangd (config.h couldn't be found, undefined symbols, etc.)
Expected behavior
Cland should resolve header inclusions and symbols.
Additional information
Following the cland documentation :
clangd will look in the parent directories of the files you edit looking for it, and also in subdirectories named build/. For example, if editing $SRC/gui/window.cpp
, we search in $SRC/gui/
, $SRC/gui/build/
, $SRC/
, $SRC/build/
To have a custom build path, the clangd --help
gives this option:
--compile-commands-dir=<string> - Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file
Workaround
Create a symbolic link build
, pointing to the _build
repository, so clangd can index the code in your project.
Edited by Sylvain PHILIP