From daede03dc6ba55d8d4dc9d9e9210e8302b127c85 Mon Sep 17 00:00:00 2001 From: Sofus Addington Date: Sun, 1 Sep 2024 21:05:29 +0200 Subject: [PATCH] workspace diagnostic refresh as request --- helix-lsp/src/lib.rs | 4 ++-- helix-term/src/application.rs | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 7d6155c37..42aa1807e 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -566,6 +566,7 @@ pub enum MethodCall { RegisterCapability(lsp::RegistrationParams), UnregisterCapability(lsp::UnregistrationParams), ShowDocument(lsp::ShowDocumentParams), + WorkspaceDiagnosticRefresh, } impl MethodCall { @@ -596,6 +597,7 @@ impl MethodCall { let params: lsp::ShowDocumentParams = params.parse()?; Self::ShowDocument(params) } + lsp::request::WorkspaceDiagnosticRefresh::METHOD => Self::WorkspaceDiagnosticRefresh, _ => { return Err(Error::Unhandled); } @@ -614,7 +616,6 @@ pub enum Notification { ShowMessage(lsp::ShowMessageParams), LogMessage(lsp::LogMessageParams), ProgressMessage(lsp::ProgressParams), - WorkspaceDiagnosticRefresh, } impl Notification { @@ -641,7 +642,6 @@ impl Notification { let params: lsp::ProgressParams = params.parse()?; Self::ProgressMessage(params) } - lsp::request::WorkspaceDiagnosticRefresh::METHOD => Self::WorkspaceDiagnosticRefresh, _ => { return Err(Error::Unhandled); } diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 24bc1ae8a..0f514e271 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -703,15 +703,6 @@ impl Application { }; match notification { - Notification::WorkspaceDiagnosticRefresh => { - for document in self.editor.documents() { - let langugage_server = language_server!(); - handlers::diagnostics::pull_diagnostics_for_document( - document, - langugage_server, - ); - } - } Notification::Initialized => { let language_server = language_server!(); @@ -744,7 +735,10 @@ impl Application { language_id, )); - helix_event::dispatch(helix_view::events::DocumentDidOpen { doc }); + handlers::diagnostics::pull_diagnostics_for_document( + doc, + language_server, + ); } } Notification::PublishDiagnostics(params) => { @@ -1040,6 +1034,18 @@ impl Application { let result = self.handle_show_document(params, offset_encoding); Ok(json!(result)) } + + Ok(MethodCall::WorkspaceDiagnosticRefresh) => { + log::warn!("Sofus refresh"); + for document in self.editor.documents() { + let language_server = language_server!(); + handlers::diagnostics::pull_diagnostics_for_document( + document, + language_server, + ); + } + Ok(serde_json::Value::Null) + } }; tokio::spawn(language_server!().reply(id, reply));