Allow LSP adapters to decide, which diagnostics to underline (#31450)

Closes
https://github.com/zed-industries/zed/pull/31355#issuecomment-2910439798

<img width="1728" alt="image"
src="https://github.com/user-attachments/assets/2eaa8e9b-00bc-4e99-ac09-fceb2d932e41"
/>


Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2025-05-26 22:19:02 +03:00 committed by GitHub
parent 4c396bcc91
commit 4567360fd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 53 additions and 5 deletions

View file

@ -245,6 +245,10 @@ impl CachedLspAdapter {
self.adapter.retain_old_diagnostic(previous_diagnostic, cx)
}
pub fn underline_diagnostic(&self, diagnostic: &lsp::Diagnostic) -> bool {
self.adapter.underline_diagnostic(diagnostic)
}
pub fn diagnostic_message_to_markdown(&self, message: &str) -> Option<String> {
self.adapter.diagnostic_message_to_markdown(message)
}
@ -470,6 +474,16 @@ pub trait LspAdapter: 'static + Send + Sync {
false
}
/// Whether to underline a given diagnostic or not, when rendering in the editor.
///
/// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticTag
/// states that
/// > Clients are allowed to render diagnostics with this tag faded out instead of having an error squiggle.
/// for the unnecessary diagnostics, so do not underline them.
fn underline_diagnostic(&self, _diagnostic: &lsp::Diagnostic) -> bool {
true
}
/// Post-processes completions provided by the language server.
async fn process_completions(&self, _: &mut [lsp::CompletionItem]) {}