Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--helix-core/src/diagnostic.rs11
-rw-r--r--helix-term/src/ui/statusline.rs40
-rw-r--r--helix-view/src/gutter.rs13
3 files changed, 50 insertions, 14 deletions
diff --git a/helix-core/src/diagnostic.rs b/helix-core/src/diagnostic.rs
index b9360b52..083dbb0a 100644
--- a/helix-core/src/diagnostic.rs
+++ b/helix-core/src/diagnostic.rs
@@ -20,6 +20,17 @@ impl Default for Severity {
}
}
+impl Severity {
+ pub const fn indicator(&self) -> &'static str {
+ match self {
+ Self::Hint => "○",
+ Self::Info => "●",
+ Self::Warning => "▲",
+ Self::Error => "■",
+ }
+ }
+}
+
#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
pub enum NumberOrString {
Number(i32),
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index ea3d27bd..4c96c816 100644
--- a/helix-term/src/ui/statusline.rs
+++ b/helix-term/src/ui/statusline.rs
@@ -237,24 +237,36 @@ where
for sev in &context.editor.config().statusline.diagnostics {
match sev {
Severity::Hint if hints > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("hint")));
+ write(
+ context,
+ Span::styled(Severity::Hint.indicator(), context.editor.theme.get("hint")),
+ );
write(context, format!(" {} ", hints).into());
}
Severity::Info if info > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("info")));
+ write(
+ context,
+ Span::styled(Severity::Info.indicator(), context.editor.theme.get("info")),
+ );
write(context, format!(" {} ", info).into());
}
Severity::Warning if warnings > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("warning")),
+ Span::styled(
+ Severity::Warning.indicator(),
+ context.editor.theme.get("warning"),
+ ),
);
write(context, format!(" {} ", warnings).into());
}
Severity::Error if errors > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("error")),
+ Span::styled(
+ Severity::Error.indicator(),
+ context.editor.theme.get("error"),
+ ),
);
write(context, format!(" {} ", errors).into());
}
@@ -304,24 +316,36 @@ where
for sev in sevs_to_show {
match sev {
Severity::Hint if hints > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("hint")));
+ write(
+ context,
+ Span::styled(Severity::Hint.indicator(), context.editor.theme.get("hint")),
+ );
write(context, format!(" {} ", hints).into());
}
Severity::Info if info > 0 => {
- write(context, Span::styled("●", context.editor.theme.get("info")));
+ write(
+ context,
+ Span::styled(Severity::Info.indicator(), context.editor.theme.get("info")),
+ );
write(context, format!(" {} ", info).into());
}
Severity::Warning if warnings > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("warning")),
+ Span::styled(
+ Severity::Warning.indicator(),
+ context.editor.theme.get("warning"),
+ ),
);
write(context, format!(" {} ", warnings).into());
}
Severity::Error if errors > 0 => {
write(
context,
- Span::styled("●", context.editor.theme.get("error")),
+ Span::styled(
+ Severity::Error.indicator(),
+ context.editor.theme.get("error"),
+ ),
);
write(context, format!(" {} ", errors).into());
}
diff --git a/helix-view/src/gutter.rs b/helix-view/src/gutter.rs
index c2cbc0da..896c6094 100644
--- a/helix-view/src/gutter.rs
+++ b/helix-view/src/gutter.rs
@@ -75,12 +75,13 @@ pub fn diagnostic<'doc>(
})
});
diagnostics_on_line.max_by_key(|d| d.severity).map(|d| {
- write!(out, "●").ok();
- match d.severity {
- Some(Severity::Error) => error,
- Some(Severity::Warning) | None => warning,
- Some(Severity::Info) => info,
- Some(Severity::Hint) => hint,
+ let severity = d.severity();
+ out.push_str(severity.indicator());
+ match severity {
+ Severity::Error => error,
+ Severity::Warning => warning,
+ Severity::Info => info,
+ Severity::Hint => hint,
}
})
},