From 16d1d881b25d0ebe42e57ccd370d689ac648eb40 Mon Sep 17 00:00:00 2001 From: Ayoub Benali Date: Sun, 12 Mar 2023 21:03:17 +0100 Subject: [PATCH 1/2] Handle window/showMessage and display it bellow status line --- book/src/configuration.md | 3 ++- helix-term/src/application.rs | 16 +++++++++++++--- helix-view/src/editor.rs | 12 +++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index ec692cab1225..b2e6bfd884c1 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -118,7 +118,8 @@ The following statusline elements can be configured: | Key | Description | Default | | --- | ----------- | ------- | | `enable` | Enables LSP integration. Setting to false will completely disable language servers regardless of language settings.| `true` | -| `display-messages` | Display LSP progress messages below statusline[^1] | `false` | +| `display-messages` | Display LSP window/showMessage messages below statusline | `false` | +| `display-progress-messages` | Display LSP progress messages below statusline[^1] | `false` | | `auto-signature-help` | Enable automatic popup of signature help (parameter hints) | `true` | | `display-inlay-hints` | Display inlay hints[^2] | `false` | | `display-signature-help-docs` | Display docs under signature help popup | `true` | diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index c7e939959ca4..7ee2f6c14dc9 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -5,7 +5,11 @@ use helix_core::{ path::get_relative_path, pos_at_coords, syntax, Selection, }; -use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap}; +use helix_lsp::{ + lsp::{self, MessageType}, + util::lsp_pos_to_pos, + LspProgressMap, +}; use helix_view::{ align_view, document::DocumentSavedEventResult, @@ -806,7 +810,13 @@ impl Application { .insert(params.uri, params.diagnostics); } Notification::ShowMessage(params) => { - log::warn!("unhandled window/showMessage: {:?}", params); + if self.config.load().editor.lsp.display_messages { + match params.typ { + MessageType::ERROR => self.editor.set_error(params.message), + MessageType::WARNING => self.editor.set_warning(params.message), + _ => self.editor.set_status(params.message), + } + } } Notification::LogMessage(params) => { log::info!("window/logMessage: {:?}", params); @@ -890,7 +900,7 @@ impl Application { self.lsp_progress.update(server_id, token, work); } - if self.config.load().editor.lsp.display_messages { + if self.config.load().editor.lsp.display_progress_messages { self.editor.set_status(status); } } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index bbed58d6e7e6..8dd07773d1ab 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -339,7 +339,9 @@ pub fn get_terminal_provider() -> Option { pub struct LspConfig { /// Enables LSP pub enable: bool, - /// Display LSP progress messages below statusline + /// Display LSP messagess from $/progress below statusline + pub display_progress_messages: bool, + /// Display LSP messages from window/showMessage below statusline pub display_messages: bool, /// Enable automatic pop up of signature help (parameter hints) pub auto_signature_help: bool, @@ -353,6 +355,7 @@ impl Default for LspConfig { fn default() -> Self { Self { enable: true, + display_progress_messages: false, display_messages: false, auto_signature_help: true, display_signature_help_docs: true, @@ -1022,6 +1025,13 @@ impl Editor { self.status_msg = Some((error, Severity::Error)); } + #[inline] + pub fn set_warning>>(&mut self, warning: T) { + let warning = warning.into(); + log::warn!("editor warning: {}", warning); + self.status_msg = Some((warning, Severity::Warning)); + } + #[inline] pub fn get_status(&self) -> Option<(&Cow<'static, str>, &Severity)> { self.status_msg.as_ref().map(|(status, sev)| (status, sev)) From d43b02d853551b11b00c8c9d5a838a1bb62dc13c Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 18 Sep 2024 15:20:33 -0400 Subject: [PATCH 2/2] Enable `editor.lsp.display_messages` by default --- helix-view/src/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 78535ca190da..26dea3a21e59 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -442,7 +442,7 @@ impl Default for LspConfig { Self { enable: true, display_progress_messages: false, - display_messages: false, + display_messages: true, auto_signature_help: true, display_signature_help_docs: true, display_inlay_hints: false,