question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for multi-root workspaces

See original GitHub issue

As 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:open
  • Created 3 years ago
  • Reactions:3
  • Comments:23 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
HighCommander4commented, Jul 27, 2022

@tmwnewbold probably makes sense to file that as a separate issue. I would expect .clang_format to work similarly to compile_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 the workspace/workspaceFolders request.

1reaction
tmwnewboldcommented, Jul 27, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi-root Workspaces in Visual Studio Code
Multi-root Workspaces. You can work with multiple project folders in Visual Studio Code with multi-root workspaces. This can be helpful when you are...
Read more >
Support for multi root workspaces · Issue #90 - GitHub
Is there any progress? Without support of multi root workspaces is this extensions almost unusable for remote repositories with multiple remote ...
Read more >
Visual Studio Code tips for monorepo development with Multi ...
A multi-root workspace is a feature in Visual Studio Code where you can have multiple root folders in one explorer view.
Read more >
Work with multiple AL project folders within one workspace
Visual Studio Code offers the multi-root workspace feature, which enables grouping different project folders into one workspace.
Read more >
VS Code tips — Multi-root workspaces - YouTube
Today's VS Code tip: Multi-root workspacesMulti-root workspaces let you work with multiple folders in the same VS Code window.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found