Reputation: 221
I am trying to integrate clangd with VS Code using vscode-clangd extension, but I am having problem with configuring include paths...
I created additional config in VS Code settings:
"clangd.path": "path_to_clangd/bin/clangd",
"clangd.arguments": [
"-compile-commands-dir=path_to_commands/compile_commands.json"
]
but the extension reports lots of missing includes errors.
I have also tried:
"-compile-commands-dir=path_to_commands"
but this also didn't work.
Does anyone knows how to configure this extension at all? I am unable to find any documentation at this point.
Regards
Upvotes: 8
Views: 26100
Reputation: 61
This is my answer, it works:
"clangd.path": "/Users/jiewang/Library/Application Support/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/11.0.0/clangd_11.0.0/bin/clangd",
"clangd.arguments": [
"--compile-commands-dir=${workspaceFolder}/build",
"--completion-style=detailed",
"--header-insertion=never"
],
Upvotes: 6
Reputation: 2234
Your path should be directory to compile_commands.json, not file, and you need to restart the clangd by the vscode-clangd extension
settings.json
{
"cmake.buildDirectory": "${workspaceFolder}/debug",
"clangd.arguments": [
"-background-index",
"-compile-commands-dir=debug"
],
}
Restart
❯ ps -Af | grep clangd
awei 285478 282126 0 10:42 ? 00:00:03 /opt/llvm-10.0.0/bin/clangd -background-index -compile-commands-dir=debug
Upvotes: 11
Reputation: 31
It seems that the compile_commands.json has to be in the Folder root directory for the extension to find it.
I just add a symlink:
ln -s /path-to-build-dir/compile_commands.json /path-to-src-root-dir/
Upvotes: 3