2

I am using neovim with configured lsp (clangd) for a C project I'm working on. Whenever I'm inside a source .c file, the lsp works great and can locate definitions and stuff whether they're inside other source files or in one of the headers. However, the issue arises when I enter any header file. The LSP completely breaks and is not able to find almost any definitions. I figured that was due to the fact that compile_commands.json contains only entries for source files. So whenever I open a .c file, clangd knows which include paths and files to search for definitions. When I open a .h file, there is no corresponding entry inside compile_commands.json and clangd is completely lost.

My question is, what is the best way to fix this issue and get the LSP working properly when inside header files?

Also, I mentioned neovim since that is my use case, but the issue isn't (neo)vim specific. If anything it's specific to clangd, but I believe that all compile_commands.json based language servers have the same problem.

matko031
  • 53
  • 7
  • 1
    I know of that SE, but I opted for SO, since the issue is not really (neo)vim specific. It's more related to clangd and how `compile_commands.json` works in general. I added an edit to clarify that in the original question. – matko031 Jun 01 '23 at 13:26

0 Answers0