summaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorMichael Davis2024-03-02 04:37:11 +0000
committerGitHub2024-03-02 04:37:11 +0000
commit5ca6a448e9b66f4f5b4caa7cd173252d0a78f92d (patch)
treea54d58501fe130c90542f4cd1adf96c4ae927b35 /helix-term
parent1d6db30acf91ec1041e014650bf263defdc3feee (diff)
Support LSP diagnostic tags (#9780)
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index dffaeea0..f3bba5d1 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -360,7 +360,7 @@ impl EditorView {
doc: &Document,
theme: &Theme,
) -> [Vec<(usize, std::ops::Range<usize>)>; 5] {
- use helix_core::diagnostic::Severity;
+ use helix_core::diagnostic::{DiagnosticTag, Severity};
let get_scope_of = |scope| {
theme
.find_scope_index_exact(scope)
@@ -380,6 +380,10 @@ impl EditorView {
let error = get_scope_of("diagnostic.error");
let r#default = get_scope_of("diagnostic"); // this is a bit redundant but should be fine
+ // Diagnostic tags
+ let unnecessary = theme.find_scope_index_exact("diagnostic.unnecessary");
+ let deprecated = theme.find_scope_index_exact("diagnostic.deprecated");
+
let mut default_vec: Vec<(usize, std::ops::Range<usize>)> = Vec::new();
let mut info_vec = Vec::new();
let mut hint_vec = Vec::new();
@@ -396,6 +400,15 @@ impl EditorView {
_ => (&mut default_vec, r#default),
};
+ let scope = diagnostic
+ .tags
+ .first()
+ .and_then(|tag| match tag {
+ DiagnosticTag::Unnecessary => unnecessary,
+ DiagnosticTag::Deprecated => deprecated,
+ })
+ .unwrap_or(scope);
+
// If any diagnostic overlaps ranges with the prior diagnostic,
// merge the two together. Otherwise push a new span.
match vec.last_mut() {