Skip to content

Commit

Permalink
Handle window/showMessage and display it bellow status line
Browse files Browse the repository at this point in the history
This feature is also hidden behind the `display-messages` which is used for displaying [Progress](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#progress).

Fix #5524
  • Loading branch information
ayoub-benali committed Jan 22, 2023
1 parent d99a720 commit 663a2e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 12 additions & 2 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -818,7 +822,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);
Expand Down
7 changes: 7 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,13 @@ impl Editor {
self.status_msg = Some((error, Severity::Error));
}

#[inline]
pub fn set_warning<T: Into<Cow<'static, str>>>(&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))
Expand Down

0 comments on commit 663a2e5

Please sign in to comment.