Automatically reload project info on Cargo.toml changes

This commit is contained in:
Aleksey Kladov
2020-07-10 15:27:34 +02:00
parent 5fa8f8e376
commit d0a8f6a3eb
7 changed files with 57 additions and 28 deletions

View File

@@ -314,19 +314,6 @@ impl GlobalState {
Ok(())
}
fn transition(&mut self, new_status: Status) {
self.status = Status::Ready;
if self.config.client_caps.status_notification {
let lsp_status = match new_status {
Status::Loading => lsp_ext::Status::Loading,
Status::Ready => lsp_ext::Status::Ready,
Status::Invalid => lsp_ext::Status::Invalid,
Status::NeedsReload => lsp_ext::Status::NeedsReload,
};
self.send_notification::<lsp_ext::StatusNotification>(lsp_status);
}
}
fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> {
self.register_request(&req, request_received);
@@ -441,12 +428,7 @@ impl GlobalState {
if let Some(flycheck) = &this.flycheck {
flycheck.handle.update();
}
let uri = params.text_document.uri.as_str();
if uri.ends_with("Cargo.toml") || uri.ends_with("Cargo.lock") {
if matches!(this.status, Status::Ready | Status::Invalid) {
this.transition(Status::NeedsReload);
}
}
this.maybe_refresh(params.text_document.uri.as_str());
Ok(())
})?
.on::<lsp_types::notification::DidChangeConfiguration>(|this, _params| {