-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
In-server cargo check watching #2668
Conversation
Does https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#progress help here? |
Amazing, that seems to be just the kind of notification we'd need! They must be reading our collective minds. |
Still keeps tests around for reference when porting them to rust
I decided against the changing anything with regard to |
Okay, looks good to me, but this is large enough to need a couple eyes. Key points:
|
@@ -0,0 +1,1316 @@ | |||
//! cargo_check provides the functionality needed to run `cargo check` or | |||
//! another compatible command (f.x. clippy) in a background thread and provide | |||
//! LSP diagnostics based on the output of the command. |
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.
This module/crate would benefit from discussing our threading/scheduling/cancellation model. Like, how many threads do we use them, when we fire them up, how we make sure they are cleanly joined.
I've looked through this, and in general I like it! This is already big, so I am biased towards merging this sooner, rather than later, and fixing the fallout, rather than trying to do the perfect thing from the first try. To do this, I think the main pre-requsite would be:
It would also be nice, but not strictly necessary, to figure out the cancellation story from the start (as it might affect the overall design quite a bit). |
@matklad I've pushed some commits extracting the code into a For shutdown or cancellation, dropping the corresponding struct always does "the right thing", e.g shutting down the thread and waiting for it to end. Hope that makes sense! |
Even though this didn't error, it became clear to me that it was closing the wrong channel, resulting in the child thread never finishing.
I tried this out, and while it works great, I'm seeing some constant CPU usage from crossbeam |
@flodiebold I might know how to fix that. It's probably because the sub-process wrapper thread is ended, so one of the channels being selected from is always "ready", in that it always has a |
There we go, that solves the issue on my end. @flodiebold Thanks for spotting it! |
That indeed fixes it! 👍 |
LGTM! bors r+ |
2668: In-server cargo check watching r=matklad a=kiljacken Opening a draft now so people can follow the progress, and comment if they spot something stupid. Things that need doing: - [x] Running cargo check on save - [x] Pipe through configuration options from client - [x] Tests for parsing behavior - [x] Remove existing cargo watch support from VSCode extension - [x] Progress notification in VSCode extension using LSP 3.15 `$/progress` notification - [ ] ~~Rework ra-ide diagnostics to support secondary messages~~ - [ ] ~~Make cargo-check watcher use ra-ide diagnostics~~ ~~I'd love some input on whether to try to keep the status bar progress thingy for VSCode? It will require some plumbing, and maintaining yet another rust-analyzer specific LSP notification, which I'm not sure we want to.~~ Fixes #1894 Co-authored-by: Emil Lauridsen <mine809@gmail.com>
Build succeeded
|
Opening a draft now so people can follow the progress, and comment if they spot something stupid.
Things that need doing:
$/progress
notificationRework ra-ide diagnostics to support secondary messagesMake cargo-check watcher use ra-ide diagnosticsI'd love some input on whether to try to keep the status bar progress thingy for VSCode? It will require some plumbing, and maintaining yet another rust-analyzer specific LSP notification, which I'm not sure we want to.Fixes #1894