mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
Handle window/showMessage and display it bellow status line (#5535)
* Handle window/showMessage and display it bellow status line * Enable `editor.lsp.display_messages` by default --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
parent
a7b8b27abf
commit
b85e824ba9
@ -846,7 +846,15 @@ macro_rules! language_server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notification::ShowMessage(params) => {
|
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) => {
|
Notification::LogMessage(params) => {
|
||||||
log::info!("window/logMessage: {:?}", params);
|
log::info!("window/logMessage: {:?}", params);
|
||||||
@ -930,7 +938,7 @@ macro_rules! language_server {
|
|||||||
self.lsp_progress.update(server_id, token, work);
|
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);
|
self.editor.set_status(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,9 @@ pub fn get_terminal_provider() -> Option<TerminalConfig> {
|
|||||||
pub struct LspConfig {
|
pub struct LspConfig {
|
||||||
/// Enables LSP
|
/// Enables LSP
|
||||||
pub enable: bool,
|
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,
|
pub display_messages: bool,
|
||||||
/// Enable automatic pop up of signature help (parameter hints)
|
/// Enable automatic pop up of signature help (parameter hints)
|
||||||
pub auto_signature_help: bool,
|
pub auto_signature_help: bool,
|
||||||
@ -439,7 +441,8 @@ impl Default for LspConfig {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
enable: true,
|
enable: true,
|
||||||
display_messages: false,
|
display_progress_messages: false,
|
||||||
|
display_messages: true,
|
||||||
auto_signature_help: true,
|
auto_signature_help: true,
|
||||||
display_signature_help_docs: true,
|
display_signature_help_docs: true,
|
||||||
display_inlay_hints: false,
|
display_inlay_hints: false,
|
||||||
@ -1271,6 +1274,13 @@ pub fn set_error<T: Into<Cow<'static, str>>>(&mut self, error: T) {
|
|||||||
self.status_msg = Some((error, Severity::Error));
|
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]
|
#[inline]
|
||||||
pub fn get_status(&self) -> Option<(&Cow<'static, str>, &Severity)> {
|
pub fn get_status(&self) -> Option<(&Cow<'static, str>, &Severity)> {
|
||||||
self.status_msg.as_ref().map(|(status, sev)| (status, sev))
|
self.status_msg.as_ref().map(|(status, sev)| (status, sev))
|
||||||
|
Loading…
Reference in New Issue
Block a user