Open planetoryd opened 9 months ago
A fork of yours seeems to work https://open-vsx.org/vscode/item?itemName=EclipseSource.vscode-clangd-multi-project
I'm sorry, it's not clear to me from your screenshots what the problem is.
Can you please describe what you're expecting to happen, and what happens that's different from what you expect?
The header files were interpreted as c++ files, but I am actually looking at C code.
I have configured it to use -xc
and -xc-header
in the config files in project root, but it doesn't work.
The version of vscode plugin in this repo doesn't work as expected, but I found a fork that works.
Ah, I see.
The reason the config file in the project root does not apply to system headers is that project config files are scoped to the directory they're located in (i.e. they will only apply to files in that directory tree).
One way to make this work is to use the --compile-commands-dir
command line option to clangd with the project directory as argument (assuming the directory contains a compile_commands.json
file). Clangd will then use this compile_commands.json
file for any file opened by the clangd instance, even if it's outside the directory. If the commands in this file contain -xc
, then opened headers will be parsed as C headers.
I just generated one item of compile_commands with bear
(It's compiled with cc
directly). Does it mean i have to run it for every file. In any case it feels awkward
Ah, I overlooked you were using compile_flags.txt
.
I checked, --compile-commands-dir
actually works with compile_flags.txt
as well. So, just putting -xc
into compile_flags.txt
and using --compile-commands-dir
should do it.
I am in a directory with only individual .c files because it's https://github.com/AllAlgorithms/c