Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code clangd extension configuration [duplicate]

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

like image 571
Darek Avatar asked Jun 09 '26 09:06

Darek


1 Answers

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

  1. change a bit of .clang-tidy file under your project root directory, if no, create one with something
  2. the vscode-clangd will prompt you to restart the clangd
  3. check the clangd process, it should something similar to
❯ 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
like image 70
Sunding Wei Avatar answered Jun 11 '26 23:06

Sunding Wei