Skip to content

Commit 8a36306

Browse files
sigmaSdFrederik Vestre
authored andcommitted
feat(lsp): add support for lsp Diagnostic{}.data (helix-editor#4935)
1 parent 968262a commit 8a36306

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

helix-core/src/diagnostic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ pub struct Diagnostic {
4545
pub code: Option<NumberOrString>,
4646
pub tags: Vec<DiagnosticTag>,
4747
pub source: Option<String>,
48+
pub data: Option<serde_json::Value>,
4849
}

helix-lsp/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,17 @@ pub mod util {
102102
None
103103
};
104104

105-
// TODO: add support for Diagnostic.data
106-
lsp::Diagnostic::new(
107-
range_to_lsp_range(doc, range, offset_encoding),
105+
lsp::Diagnostic {
106+
range: range_to_lsp_range(doc, range, offset_encoding),
108107
severity,
109108
code,
110-
diag.source.clone(),
111-
diag.message.to_owned(),
112-
None,
109+
source: diag.source.clone(),
110+
message: diag.message.to_owned(),
111+
related_information: None,
113112
tags,
114-
)
113+
data: diag.data.to_owned(),
114+
..Default::default()
115+
}
115116
}
116117

117118
/// Converts [`lsp::Position`] to a position in the document.

helix-term/src/application.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,8 @@ impl Application {
772772
severity,
773773
code,
774774
tags,
775-
source: diagnostic.source.clone()
775+
source: diagnostic.source.clone(),
776+
data: diagnostic.data.clone(),
776777
})
777778
})
778779
.collect();

0 commit comments

Comments
 (0)