rust-lang/rust-analyzer

Add "Open Cargo.toml" action

matklad opened this issue · 7 comments

Invoking it should open Cargo.toml for the current file.

This should be implemented at the rust-analyzer layer (ie, not in the IDE layer).

This needs custom protocol extension.

See c9f8789#diff-4bec6bfceb4323ffd0d2ff1ad25070234f084f31ddd5577bbdb510de878a3811 for an example which adds custom extension

I can take this up if no one else is working on it. This would open the Cargo.toml of the current crate, right?

Yes, but there might be some corner cases:

  • the project is not Cargo-based
  • the file is generated by a build script
  • the file is included in multiple crates

This would open the Cargo.toml of the current crate, right?

Right! i suggest looking at handle_runnables for the logic of discovering the current crate/package

Thanks @matklad, @lnicola. This might not be the right place to ask this, but how can I actually go about testing this? It seems like this would involves changes to both client + server, and looking at ./docs/dev.md, it just says that there is no specific workflow for this case.

We just don't such features -- there's relatively few bugs on the interesection between client and server, and conventinal testing is not too efficient here.

ah, got it 👍. What about manually verifying it works? Like installing a dev build and running that in vscode?

@p3achyjr you can uninstall the store extension, run cargo xtask install in a clone of the repository, and maybe update rust-analyzer.serverPath to point to the executable in ~/cargo/bin or %HOME%\.cargo\bin (it might not be in PATH).