-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
internal: Add Cargo-style project discovery for Buck and Bazel Users #14307
internal: Add Cargo-style project discovery for Buck and Bazel Users #14307
Conversation
I feel like an cc #13446 |
I can see how that approach is better. I think it'd allow for a Buck/Bazel extension to manage linked projects and (potentially) surface them through a UI and mapping each linked project to a BUILD/BUCK file. One question, though: |
Yes, I forgot to add that, we'd still need this to be a request, repurposing
LSP already has a configuration changed notification so we could also re-use this and just update the linked projects key there. The main problem here is figuring out how to shove an "inline" rust project specification into there since right not this takes a list of file paths only |
Thankfully, we don't need to figure this out! Just to make sure I understand, we want to do:
|
I've added a workspace configuration-based approach to reloading the workspace in cef2d62. I haven't removed the |
This feature requires the user to add a command that generates a `rust-project.json` from a set of files. Project discovery can be invoked in two ways: 1. At extension activation time, which includes the generated `rust-project.json` as part of the linkedProjects argument in InitializeParams 2. Through a new command titled "Add current file to workspace", which makes use of a new, rust-analyzer specific LSP request that adds the workspace without erasing any existing workspaces. I think that the command-running functionality _could_ merit being placed into its own extension (and expose it via extension contribution points), if only provide build-system idiomatic progress reporting and status handling, but I haven't (yet) made an extension that does this.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
…to avoid failing tests
…iguration has changed
ecc1de5
to
56273b3
Compare
I think I've addressed all the comments:
|
Will take a proper look tomorrow but
fully agree with this, we should not be changing the user config. We only need to synthesize the |
No worries, take care!
Yup, that's the approach that I took here. It seems like the config was written out to the workspace-level
He was. I tried a different approach, and when that I didn't work out, I was able to get this approach working in about 2 days. I'm a bit annoyed with myself that I didn't listen to him first! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing
I am not sure whether this is the right way we want to tackle this (that is having this command be part of r-a in long term), but for the time being I'd say that's okay. |
My feeling is that I'd like to get some user feedback first, but I strongly suspect that this should live in an external extension that rust-analyzer coordinates with. I don't expect rust-analyzer to worry about maintaining this for an extended period of time. |
Sorry about the back and forth, but thank you for your patience :) |
@bors r+ |
☀️ Test successful - checks-actions |
When is the discovery command run? Is it run in lieu of opening a |
@woody77 At the moment, it can run in two situations:
To be entirely honest, I think I was a bit too conservative with the latter option. I think that we should be probably be running the discovery command each time the user opens a Rust file that isn't part of the current workspace—rust-analyzer is stupidly fast at loading projects, and getting the results from Buck takes a few seconds at worst. |
This feature requires the user to add a command that generates a
rust-project.json
from a set of files. Project discovery can be invoked in two ways:rust-project.json
as part of the linkedProjects argument inInitializeParams
.Few notes:
I'd love to get feedback on:
rust-analyzer.discoverProjectCommand
on being set, so I can add this in sequent commits.(I previously tried to add this functionality entirely within rust-analyzer-the-LSP server itself, but matklad was right—an extension side approach is much, much easier.)