Is there "includePath" option in clangd?

AMIR REZA SADEQI picture AMIR REZA SADEQI · Apr 14, 2020 · Viewed 9.9k times · Source

I used to work with VSCode C/C++ extension. there was a feature in this extension(in a json file), called "includePath", which I could set the paths for my headers, so without execution of CMake or make, I would have the suggestion of my headers and code completion from those.

now I have switched to neovim and clangd as the language server for code completion. I searched a lot to find the corresponding feature in clangd options but I could not find anything more than this link.

since the clangd is a powerful language server, I am in wonder if there is not such a feature in it. so I want to know is there actually such a feature in clangd? and if YES how can I use that?

Note: I use a language client, called "coc-clangd". I don't know if it matters or not.

Answer

hideDragon picture hideDragon · Sep 21, 2021

Maybe this is useful: https://clangd.llvm.org/config

Create a file called '.clangd' in the top-level of the source directory. Add those content.

CompileFlags: # Tweak the parse settings
  Add: 
    - "-I=[folder]"

But I think this is not recommend, all include directories should be add in CMakeLists.txt file.