clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
644 stars 113 forks source link

can we run clangd per project (per root dir) #705

Closed braindevices closed 1 month ago

braindevices commented 1 month ago

in most other IDE, the clangd is per project which allow us easily work with different llvm version, different libraries, etc.

We basically need the clangd to parse different compile_commands.json for different root dir. This is especially important for multiple projects or multiple roots workspace.

Currently implementation of clangd server only start single process for the entire workspace, which is wrong.

HighCommander4 commented 1 month ago

Using a single process for the entire workspace is a deliberate design choice, as it allows things like navigation between a use of a symbol in one project, and its definition in a dependent project.

Note that this does not preclude using different compile_commands.json files for different root directories. Clangd searches for compile_commands.json in the ancestor directories of the source file being opened, so e.g. having a different compile_commands.json file in each top-level subdirectory of the workspace should work out of the box.

There is a fork of vscode-clangd which has the process-per-project behaviour you describe, at https://github.com/eclipse-cdt-cloud/vscode-clangd.

HighCommander4 commented 1 month ago

Duplicate of https://github.com/clangd/vscode-clangd/issues/498