I would have a
compile_commands.json in the root of my project.
I make sure it is the working directory (using vim-rooter may help for that) but I'm not sure it is a requirement.
compile_commands.json would contains the instructions to build each of the
For a project like:
| |_ main.cpp
| |_ foo.cpp
| |_ include
| |_ foo.h
"command": "clang++.exe -x c++ main.cpp -std=c++2b -DMYFLAG1 -DMYFLAG2 -Iinclude -I../project2/include",
"command": "clang++.exe -x c++ foo.cpp -std=c++2b -DMYFLAG1 -DMYFLAG2 -Iinclude",
In order to debug your
compile_commands.json the following command is helpful:
It allow to to verify that:
compile_commands.json is correctly identified
- The resulting compilation flag for the selected file (
project2/foo.cpp in the example)
If that is too much work you could also only have a flag with common compiler flags (it provides already some information about the available includes to clangd). It allow to navigate through the includes and to the declaration but not to the definition.