-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add multi project support vscode #3972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multi project support vscode #3972
Conversation
… to be cwd of the RA server
… and finding the cargo toml that belongs to that file
… to have many simultaniously running.
…with a Cargo.toml
* it only looks at files from it's ctx * uses cwd for the language server
* one status diplay per project * Will hide / show depending on the active project
|
Hmm... I was browsing through the PRs after opening my issue. Does this fix #3975 through the |
|
Hi @Ten0, I'll try to outline how it will work in more detail, hope this will clarify it, anyway here goes: workspace with multiple projects side by sideIf your structure is: Then it would work, by spinning up 2 RA-severs one with workspace with a project nested inside another projectIf your structure is: Then it would work, by spinning up 2 RA-severs on with A workspace with it's own Cargo.toml and with other projects inside it (How the RA repo is structured)Maybe this mode should just be removed Then it would work, by spinning up 1 RA-severs with Then it would see as just another form of the second setup and work by spinning up 3 RA-severs one with |
|
My structure is a bit different ^^ : How would it behave in this scenario ? Optionally I could add the Somewhat-unrelated: I feel like the double reporting problem may be linked to this discussion: #2792 Somewhat-unrelated again: I feel like when opening a workspace root, we could spin up a single workspace check, because when the workspace is large, spinning up completely separate RA processes would eat an insane amount of physical resources. |
|
I'll try to review this closely some time later today, but, generally, I think we should pursue a different, harder but more long-term viable approach (If I understood correctly what this PR doese). We should support loading several workspaces into the single rust-analyzer process. Hm, actually, looking at the code we do seem to support this? Note that I don't use this funcitonality myslf, so it might very well be broken, but in that case, I think we should fix it (and maybe add a heavy test). |
|
@matklad I actually do agree, I just saw the rewrite of RA's project selector as being too big a task for a one night project, but now that I've worked with it a bit maybe it's not too bad ;). Anyway going back to topic, there are a lot of annoyances with multiple language servers in vscode, that said this does provide the kind of functionality one would expect, and it was quite easy to implement. But I completely understand if it's preferred to wait with this until it's available inside the language server. |
|
Yeah, I guess there are two orthogonal problems here:
Dynamic reconfiguration, on the one hand, is a pretty thorny issue, but, on the other hand, the solution of "just" reloading the might not be that bad at the end of the day. The true reconfiguration is blocked on #3715 (or, more generally, on the investiagation of what dynamic root set means in the first place). However, I think we can get 80% there if we just show user a message "hey, we've noticed that you've edited Cargo.toml / added new workspace folder, you might want to reload rust-anlayzer". Is this a fair summary of the situation? Or is there something I am overlooking, which makes multi-server setup a significantly better UX? |
Yes, quite fair, with a caveat while multi-project is supported it's effectively not used in vscode (multi workspace is not very nice) that said I think it should be easy to get there. Also the multi-server solution proposed in this PR is really not a "good" solution other than it providing the "dynamic project loading", without much headache I agree 100% that the "would you like to restart?" is good enough and it expands better once dynamic project loading is ready :). That said I agree that your proposal is a bit cleaner, I don't know the design process but I wouldn't mind implementing what you proposed:
|
|
I am closing this to make way for a new redesign on: My reasoning is that there is no code overlap and instead of force pushing and making it more confusing I instead opened a new pr. |
This pr adds multi project support for vscode.
Some time ago I added this for the RLS vscode plugin: rust-lang/vscode-rust#638
And since I had some time I decided to implement it for rust-analyzer aswell.
The design is simple (can be expanded upon):
Cargo.tomlfile, and create an RA-server, if another document shares the sameCargo.tomlthen it will also share that RA-server, otherwise a new will be spawned.Ctx.Some caveats / things that could be done better or different:
Also I haven't been part of any design discussions so if this had already been decided against for other reasons that's fair :)