Open davidbarsky opened 1 month ago
For reference, the Buck-side implementation of this can be found here: https://github.com/facebook/buck2/tree/main/integrations/rust-project/src
Hi, @davidbarsky I read a few of the discussions on RAtoml (including: https://github.com/rust-lang/rust-analyzer/pull/17246). But I don't fully understand the concept/advantages of ra's automatic project discovery. Would you mind explaining? In what ways will it improve the Rust Bazel IDE experience?
But I don't fully understand the concept/advantages of ra's automatic project discovery. Would you mind explaining? In what ways will it improve the Rust Bazel IDE experience?
I think it improves the situation in two major ways:
rust-project.json
for the entire workspace. In my opinion as a rust-analyzer team member, this has two downsides:
rust-project.json
for the entire workspace might not scale to larger workspaces. I don't believe this is an inherent limitation to @rules_rust//tools/rust_analyzer:gen_rust_project
, but https://github.com/rust-lang/rust-analyzer/pull/17246 can be substantially more fine-grained with what is and isn't indexed.@rules_rust//tools/rust_analyzer:gen_rust_project
runs on editor starting up, but doesn't necessarily refresh the workspace if dependencies are added or removed. The PR I linked to can reload when a BUILD file changes.O(build_system)
, not O(build system * editor)
. I also think that the video I attached to the PR is pretty nice—it looks decently Cargo-like.Thanks for the explanation!
- Generating a
rust-project.json
for the entire workspace might not scale to larger workspaces. I don't believe this is an inherent limitation to@rules_rust//tools/rust_analyzer:gen_rust_project
Does this mean it could generate based on the open buffers / crate you're currently in ?
Does this mean it could generate based on the open buffers / crate you're currently in ?
Yes, but you can still can still generate a rust-project.json
for the entire workspace if somthing like /...
is provided as an argument to the command—the scaling is just a bit more graceful.
Thanks for the pointer @davidbarsky, this looks really nice!
I'd happily review a contribution if someone wanted to put one together :)
Hi @davidbarsky, I’d like to contribute, but I’ll need some guidance. It looks like I'll need to update the existing rust-project-gen similar to the one Buck has (reference above)? mainly what buck's rust-project develop(+json) and check cmds implement? What else is needed?
Does rust-analyzer provide the currently edited files?
Hi folks! I added Cargo-style automatic project discovery in rust-analyzer for non-Cargo build systems (Buck primarily, but it's designed to be usable by Bazel...) in https://github.com/rust-lang/rust-analyzer/pull/17246. The documentation for this feature is in the manual, under "rust-analyzer.workspace.discoverConfig". I've been using it with Buck for the last month and a half, and while some details are still likely to change, the general shape of the API is in a spot that I'm happy with. I think this would make the Rust IDE experience with Bazel a lot nicer and I'd be very happy to provide guidance on integrating this feature into rules_rust!