I'm trying to set up my Neovim/LSP/Clangd setup at work. We use two different ways to store source (.cpp
). and header (.h
) files. The first way is the common approach, where both the source and header files are placed in the same folder. The second way involves keeping the source files in the lib
folder and the headers in the include
folder. Additionally, all header files are symlinked in a single folder called all_includes
.
The LSP suggestions work perfectly with the example .clangd
configuration provided below:
CompileFlags:
Add: [-I../include,
-I/path/to/folder/with/all/includes/all_includes]
However, the feature of switching between source and header with ClangdSwitchSourceHeader
only works in the first approach or from source to header.
Does Clangd have an option to locate the source file in this case? I know that the source file for it is located at the path ../lib
. Is there an option to provide this information to Clang, or is there an easier solution that involves creating my own Lua function to solve this problem?