I use a single VSCode instance for working in multiple projects (Rust, NodeJS, etc.) and with different "workspaces". But rust-analyzer seems to assume that the instance only has one workspace.
Is this configurable?
Example:
I have multiple but separate projects at a path /projects, e.g. /projects/a and /projects/b.
For now, I have created a /projects/Cargo.toml with the contents
[workspace]
resolver = "2"
members = [
"/projects/*",
]
This makes rust-analyzer work. But cargo build
builds all projects.
Also, when I press the "Run" button in VSCode above "fn main()", it runs in /projects, instead of the "nearest folder with Cargo.toml", e.g. /project/a if I'm editing /project/a/src/main.rs.
The behavior in a nodejs project is to take "currently viewed file" and go up in parent folders until finding a "package.json", and then run "npm run ..." in that path.
I was expecting a similar behavior.
I think the rust-analyzer only reads the Cargo.toml file in the "root of the currently open folder", e.g. /projects/Cargo.toml. But ideally it would evaluate the currently open file, then find the nearest Cargo.toml, as the project file, and move up in parent folders until it finds a Cargo.toml with a [workspace] declaration, as its workspace configuration file.
Does this make sense?
So I would expect it to run in /projects/a/ if there was no parent workspace Cargo.toml, and otherwise in /projects.
So if I had two workspaces:
/projects/workspace1/a/main.rs
/projects/workspace2/c/main.rs
then running /projects/workspace1/a/main.rs would execute in /projects/workspace1/.
Is this configurable? Or something I should request as a feature request on GitHub?