Skip to content

Commit

Permalink
feat(lsp): add support for lsp Diagnostic{}.data (helix-editor#4935)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmaSd authored Dec 2, 2022
1 parent 8291654 commit 4960c41
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions helix-core/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ pub struct Diagnostic {
pub code: Option<NumberOrString>,
pub tags: Vec<DiagnosticTag>,
pub source: Option<String>,
pub data: Option<serde_json::Value>,
}
15 changes: 8 additions & 7 deletions helix-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,17 @@ pub mod util {
None
};

// TODO: add support for Diagnostic.data
lsp::Diagnostic::new(
range_to_lsp_range(doc, range, offset_encoding),
lsp::Diagnostic {
range: range_to_lsp_range(doc, range, offset_encoding),
severity,
code,
diag.source.clone(),
diag.message.to_owned(),
None,
source: diag.source.clone(),
message: diag.message.to_owned(),
related_information: None,
tags,
)
data: diag.data.to_owned(),
..Default::default()
}
}

/// Converts [`lsp::Position`] to a position in the document.
Expand Down
3 changes: 2 additions & 1 deletion helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ impl Application {
severity,
code,
tags,
source: diagnostic.source.clone()
source: diagnostic.source.clone(),
data: diagnostic.data.clone(),
})
})
.collect();
Expand Down

0 comments on commit 4960c41

Please sign in to comment.