on master help sign in
feat(lsp): add support for lsp Diagnostic{}.data (#4935)
4960c41sigmaSd
helix-core/src/diagnostic.rs+1
@@ -45,4 +45,5 @@ pub struct Diagnostic {
45 pub code: Option<NumberOrString>,
45 pub code: Option<NumberOrString>,
46 pub tags: Vec<DiagnosticTag>,
46 pub tags: Vec<DiagnosticTag>,
47 pub source: Option<String>,
47 pub source: Option<String>,
48+ pub data: Option<serde_json::Value>,
48}
49}
helix-lsp/src/lib.rs+8−7
@@ -102,16 +102,17 @@ pub mod util {
102 None
102 None
103 };
103 };
104
104
105− // TODO: add support for Diagnostic.data
106− lsp::Diagnostic::new(
105+ lsp::Diagnostic {
107− range_to_lsp_range(doc, range, offset_encoding),
106+ range: range_to_lsp_range(doc, range, offset_encoding),
108 severity,
107 severity,
109 code,
108 code,
110− diag.source.clone(),
109+ source: diag.source.clone(),
111− diag.message.to_owned(),
110+ message: diag.message.to_owned(),
112− None,
111+ related_information: None,
113 tags,
112 tags,
114− )
113+ data: diag.data.to_owned(),
114+ ..Default::default()
115+ }
115 }
116 }
116
117
117 /// Converts [`lsp::Position`] to a position in the document.
118 /// Converts [`lsp::Position`] to a position in the document.
helix-term/src/application.rs+2−1
@@ -772,7 +772,8 @@ impl Application {
772 severity,
772 severity,
773 code,
773 code,
774 tags,
774 tags,
775− source: diagnostic.source.clone()
775+ source: diagnostic.source.clone(),
776+ data: diagnostic.data.clone(),
776 })
777 })
777 })
778 })
778 .collect();
779 .collect();