aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 52e58163..85028e2f 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -247,17 +247,36 @@ impl EditorView {
doc: &Document,
theme: &Theme,
) -> Vec<(usize, std::ops::Range<usize>)> {
- let diagnostic_scope = theme
- .find_scope_index("diagnostic")
+ use helix_core::diagnostic::Severity;
+ let get_scope_of = |scope| {
+ theme
+ .find_scope_index(scope)
+ // get one of the themes below as fallback values
+ .or_else(|| theme.find_scope_index("diagnostic"))
.or_else(|| theme.find_scope_index("ui.cursor"))
.or_else(|| theme.find_scope_index("ui.selection"))
.expect(
"at least one of the following scopes must be defined in the theme: `diagnostic`, `ui.cursor`, or `ui.selection`",
- );
+ )
+ };
+
+ // basically just queries the theme color defined in the config
+ let hint = get_scope_of("diagnostic.hint");
+ let info = get_scope_of("diagnostic.info");
+ let warning = get_scope_of("diagnostic.warning");
+ let error = get_scope_of("diagnostic.error");
+ let r#default = get_scope_of("diagnostic"); // this is a bit redundant but should be fine
doc.diagnostics()
.iter()
.map(|diagnostic| {
+ let diagnostic_scope = match diagnostic.severity {
+ Some(Severity::Info) => info,
+ Some(Severity::Hint) => hint,
+ Some(Severity::Warning) => warning,
+ Some(Severity::Error) => error,
+ _ => r#default,
+ };
(
diagnostic_scope,
diagnostic.range.start..diagnostic.range.end,