Skip to content
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

Handle window/showMessage and display it bellow status line #5535

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,15 @@ impl Application {
}
}
Notification::ShowMessage(params) => {
log::warn!("unhandled window/showMessage: {:?}", params);
if self.config.load().editor.lsp.display_messages {
match params.typ {
lsp::MessageType::ERROR => self.editor.set_error(params.message),
lsp::MessageType::WARNING => {
self.editor.set_warning(params.message)
}
_ => self.editor.set_status(params.message),
}
}
}
Notification::LogMessage(params) => {
log::info!("window/logMessage: {:?}", params);
Expand Down Expand Up @@ -930,7 +938,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);
}
}
Expand Down
14 changes: 12 additions & 2 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ pub fn get_terminal_provider() -> Option<TerminalConfig> {
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,
Expand All @@ -439,7 +441,8 @@ impl Default for LspConfig {
fn default() -> Self {
Self {
enable: true,
display_messages: false,
display_progress_messages: false,
display_messages: true,
auto_signature_help: true,
display_signature_help_docs: true,
display_inlay_hints: false,
Expand Down Expand Up @@ -1271,6 +1274,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