Do not underline unnecessary diagnostics (#31355)
Closes https://github.com/zed-industries/zed/pull/31229#issuecomment-2906946881 Follow https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticTag > Clients are allowed to render diagnostics with this tag faded out instead of having an error squiggle. and do not underline any unnecessary diagnostic at all. Release Notes: - Fixed clangd's inactive regions diagnostics excessive highlights
This commit is contained in:
parent
6f918ed99b
commit
20a0956fb2
4 changed files with 14 additions and 40 deletions
|
@ -10,6 +10,7 @@ use crate::LspStore;
|
|||
|
||||
pub const CLANGD_SERVER_NAME: &str = "clangd";
|
||||
const INACTIVE_REGION_MESSAGE: &str = "inactive region";
|
||||
const INACTIVE_DIAGNOSTIC_SEVERITY: lsp::DiagnosticSeverity = lsp::DiagnosticSeverity::INFORMATION;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -28,7 +29,7 @@ impl lsp::notification::Notification for InactiveRegions {
|
|||
|
||||
pub fn is_inactive_region(diag: &Diagnostic) -> bool {
|
||||
diag.is_unnecessary
|
||||
&& diag.severity == lsp::DiagnosticSeverity::INFORMATION
|
||||
&& diag.severity == INACTIVE_DIAGNOSTIC_SEVERITY
|
||||
&& diag.message == INACTIVE_REGION_MESSAGE
|
||||
&& diag
|
||||
.source
|
||||
|
@ -59,11 +60,11 @@ pub fn register_notifications(
|
|||
.into_iter()
|
||||
.map(|range| lsp::Diagnostic {
|
||||
range,
|
||||
severity: Some(lsp::DiagnosticSeverity::INFORMATION),
|
||||
severity: Some(INACTIVE_DIAGNOSTIC_SEVERITY),
|
||||
source: Some(CLANGD_SERVER_NAME.to_string()),
|
||||
message: INACTIVE_REGION_MESSAGE.to_string(),
|
||||
tags: Some(vec![lsp::DiagnosticTag::UNNECESSARY]),
|
||||
..Default::default()
|
||||
..lsp::Diagnostic::default()
|
||||
})
|
||||
.collect();
|
||||
let mapped_diagnostics = lsp::PublishDiagnosticsParams {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue