lsp: Add support for ShowMessage notification (#14012)
When "one newer language" sends these messages, "one newer editor" will display a pop-up for users to see. :) Related to https://github.com/gleam-lang/gleam/issues/3274  Release Notes: - A certain popular language recently had to work around a missing LSP notification. This has been fixed
This commit is contained in:
parent
8cfa690271
commit
09e7b481b8
1 changed files with 44 additions and 21 deletions
|
@ -3676,29 +3676,26 @@ impl Project {
|
|||
let this = this.clone();
|
||||
let name = name.to_string();
|
||||
async move {
|
||||
if let Some(actions) = params.actions {
|
||||
let (tx, mut rx) = smol::channel::bounded(1);
|
||||
let request = LanguageServerPromptRequest {
|
||||
level: match params.typ {
|
||||
lsp::MessageType::ERROR => PromptLevel::Critical,
|
||||
lsp::MessageType::WARNING => PromptLevel::Warning,
|
||||
_ => PromptLevel::Info,
|
||||
},
|
||||
message: params.message,
|
||||
actions,
|
||||
response_channel: tx,
|
||||
lsp_name: name.clone(),
|
||||
};
|
||||
let actions = params.actions.unwrap_or_default();
|
||||
let (tx, mut rx) = smol::channel::bounded(1);
|
||||
let request = LanguageServerPromptRequest {
|
||||
level: match params.typ {
|
||||
lsp::MessageType::ERROR => PromptLevel::Critical,
|
||||
lsp::MessageType::WARNING => PromptLevel::Warning,
|
||||
_ => PromptLevel::Info,
|
||||
},
|
||||
message: params.message,
|
||||
actions,
|
||||
response_channel: tx,
|
||||
lsp_name: name.clone(),
|
||||
};
|
||||
|
||||
if let Ok(_) = this.update(&mut cx, |_, cx| {
|
||||
cx.emit(Event::LanguageServerPrompt(request));
|
||||
}) {
|
||||
let response = rx.next().await;
|
||||
if let Ok(_) = this.update(&mut cx, |_, cx| {
|
||||
cx.emit(Event::LanguageServerPrompt(request));
|
||||
}) {
|
||||
let response = rx.next().await;
|
||||
|
||||
Ok(response)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
Ok(response)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
@ -3753,7 +3750,33 @@ impl Project {
|
|||
}
|
||||
})
|
||||
.detach();
|
||||
language_server
|
||||
.on_notification::<lsp::notification::ShowMessage, _>({
|
||||
let this = this.clone();
|
||||
let name = name.to_string();
|
||||
move |params, mut cx| {
|
||||
let this = this.clone();
|
||||
let name = name.to_string();
|
||||
|
||||
let (tx, _) = smol::channel::bounded(1);
|
||||
let request = LanguageServerPromptRequest {
|
||||
level: match params.typ {
|
||||
lsp::MessageType::ERROR => PromptLevel::Critical,
|
||||
lsp::MessageType::WARNING => PromptLevel::Warning,
|
||||
_ => PromptLevel::Info,
|
||||
},
|
||||
message: params.message,
|
||||
actions: vec![],
|
||||
response_channel: tx,
|
||||
lsp_name: name.clone(),
|
||||
};
|
||||
|
||||
let _ = this.update(&mut cx, |_, cx| {
|
||||
cx.emit(Event::LanguageServerPrompt(request));
|
||||
});
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
language_server
|
||||
.on_notification::<lsp::notification::Progress, _>(move |params, mut cx| {
|
||||
if let Some(this) = this.upgrade() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue