Support for multi-root workspaces
See original GitHub issueAs multi-root workspaces become more popular and widely adopted, it would be great if vscode-clangd
could support this as well.
There are many use-cases for C/C++ projects where this would be useful (working with different hardware targets, working across third party libraries, etc.). I imagine there would need to be a fair amount of discussion on how to approach this. Some items for debate are whether the plugin should spawn an instance of clangd per root or whether it should be allowed for the client to specify multiple compilation databases.
Some relevant links to study on the LSP side are the vscode LSP multi-server example which illustrates how to start a server per wokspace folder, and the LSP specification for handling workspace folders. Feel free to discuss below any ideas for how to implement this!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:23 (8 by maintainers)
Top GitHub Comments
@tmwnewbold probably makes sense to file that as a separate issue. I would expect
.clang_format
to work similarly tocompile_commands.json
(looked up based on the directory of the file being edited), so if that’s not working you may be running into a bug that’s unrelated to clangd’s lack of support for theworkspace/workspaceFolders
request.Many (most?) of clangd’s features do seem to be working for me in multi-root workspaces (using VSCode 1.69.2 and clangd v0.1.21 as of today). It’s correctly finding the compile-commands.json files that exist in each workspace root, and is thus providing completions, go-to-definition and other source navigation operations as expected.
But one of the glaring exceptions is the support for clang-format. clangd appears to run with a current working directory inside the first root in the workspace and unconditionally uses the _clang-format file found there (or in a parent of that directory) even when there are (differing) _clang-format files in each of the workspace roots.
As much as one might hope otherwise, different groups at my company have very different ideas about how to format code. This goes terribly wrong when I build a workspace with components from different groups and code starts getting reformatted in unexpected ways.