Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there "includePath" option in clangd?

Tags:

c++

c

neovim

clangd

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.

like image 441
AMIR REZA SADEQI Avatar asked Aug 31 '25 01:08

AMIR REZA SADEQI


1 Answers

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, example directory given to show format
  Add:
    # - "-I=[folder]"         # old answer
    - "-I[folder]"            # e.g `-I/usr/include/SDL2`  suggested from @Palmkeep

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

like image 186
Aincvy Avatar answered Sep 02 '25 15:09

Aincvy