rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Feature Request: VS Code GUI to indicate paths to analyze

Open bionicles opened this issue 1 year ago • 1 comments

Hello all,

  • Why: reduce context switching costs due to changing VS code windows
  • How: enable whole-linux-machine Rust Analyzer w/ path-to-cargo-toml toggles

This feature request is meant to resolve this issue where we're forced to work with VS code like this:

image

if we have to open each folder in a separate vs code window then it can become annoying to figure out which window is which and switch around, and there's not really enough room sometimes. It's great to be able to do that, but it's annoying to be forced to do that, if I make sense. If you randomly want to look at code from another repo, you need to hover over the vs code button and know which window (labeled by file open, not project open, mind you) to click on.

I want to be able to open VS code on the root of a Linux machine or from the home directory, and be able to tell Rust Analyzer which cargo.toml files to analyze, and be able to toggle paths on and off, would this be possible? The main benefit would be, if we have a variety of projects to work on, if we just have the whole linux machine in VS code explorer, then we can more fluidly hop between different projects.

Here's a sketch of the proposal, this could potentially be recursive down into nested workspaces but that could be hard to fit into the available space, maybe image

It might be good to have inside Cargo.toml not only a list of workspace members available, but also a separate list of which members to analyze. This would be a natural place to store information about what to analyze, although could yield merge conflicts if teammates work on different chunks of rust.

Once again, the main goal would just be to reduce the need to switch between various VS code windows to look at different rust crates, and adding a few checkboxes to potentially save us from switching windows millions of times sounds like a good deal to me.

However, as I'm a Rust newbie unfamiliar with this codebase, I can't ship this efficiently,

also,

  • I could be wrong about how to do this, and
  • I could be wrong about if it is even necessary,

Therefore, please feel welcome to chime in if you have better ideas to address the same issue or if you think it is not an issue (any good workarounds?)

bionicles avatar Jun 07 '24 11:06 bionicles

As you realized, you can get something like this (but without the UI or Cargo.toml integration) using workspaces, the linkedProjects setting, or rust-project.json, but I'm not sure I understand the use case. If you just want to look at the crates you're using (transitive dependencies of your project), there's a nifty panel listing all of them:

image

If you want to browse other random crates, adding them to your workspace might be too much. But an option would be to have two Code instances:

  • one for the actual project you're working on
  • one Code workspace as a playground:

image

lnicola avatar Jun 10 '24 04:06 lnicola