mirror of https://github.com/helix-editor/helix
Merge e38a432a00
into ba54b6afe4
commit
472c44d83b
|
@ -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)]
|
#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
|
||||||
pub enum NumberOrString {
|
pub enum NumberOrString {
|
||||||
Number(i32),
|
Number(i32),
|
||||||
|
|
|
@ -237,24 +237,36 @@ where
|
||||||
for sev in &context.editor.config().statusline.diagnostics {
|
for sev in &context.editor.config().statusline.diagnostics {
|
||||||
match sev {
|
match sev {
|
||||||
Severity::Hint if hints > 0 => {
|
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());
|
write(context, format!(" {} ", hints).into());
|
||||||
}
|
}
|
||||||
Severity::Info if info > 0 => {
|
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());
|
write(context, format!(" {} ", info).into());
|
||||||
}
|
}
|
||||||
Severity::Warning if warnings > 0 => {
|
Severity::Warning if warnings > 0 => {
|
||||||
write(
|
write(
|
||||||
context,
|
context,
|
||||||
Span::styled("●", context.editor.theme.get("warning")),
|
Span::styled(
|
||||||
|
Severity::Warning.indicator(),
|
||||||
|
context.editor.theme.get("warning"),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
write(context, format!(" {} ", warnings).into());
|
write(context, format!(" {} ", warnings).into());
|
||||||
}
|
}
|
||||||
Severity::Error if errors > 0 => {
|
Severity::Error if errors > 0 => {
|
||||||
write(
|
write(
|
||||||
context,
|
context,
|
||||||
Span::styled("●", context.editor.theme.get("error")),
|
Span::styled(
|
||||||
|
Severity::Error.indicator(),
|
||||||
|
context.editor.theme.get("error"),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
write(context, format!(" {} ", errors).into());
|
write(context, format!(" {} ", errors).into());
|
||||||
}
|
}
|
||||||
|
@ -304,24 +316,36 @@ where
|
||||||
for sev in sevs_to_show {
|
for sev in sevs_to_show {
|
||||||
match sev {
|
match sev {
|
||||||
Severity::Hint if hints > 0 => {
|
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());
|
write(context, format!(" {} ", hints).into());
|
||||||
}
|
}
|
||||||
Severity::Info if info > 0 => {
|
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());
|
write(context, format!(" {} ", info).into());
|
||||||
}
|
}
|
||||||
Severity::Warning if warnings > 0 => {
|
Severity::Warning if warnings > 0 => {
|
||||||
write(
|
write(
|
||||||
context,
|
context,
|
||||||
Span::styled("●", context.editor.theme.get("warning")),
|
Span::styled(
|
||||||
|
Severity::Warning.indicator(),
|
||||||
|
context.editor.theme.get("warning"),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
write(context, format!(" {} ", warnings).into());
|
write(context, format!(" {} ", warnings).into());
|
||||||
}
|
}
|
||||||
Severity::Error if errors > 0 => {
|
Severity::Error if errors > 0 => {
|
||||||
write(
|
write(
|
||||||
context,
|
context,
|
||||||
Span::styled("●", context.editor.theme.get("error")),
|
Span::styled(
|
||||||
|
Severity::Error.indicator(),
|
||||||
|
context.editor.theme.get("error"),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
write(context, format!(" {} ", errors).into());
|
write(context, format!(" {} ", errors).into());
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,12 +75,13 @@ pub fn diagnostic<'doc>(
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
diagnostics_on_line.max_by_key(|d| d.severity).map(|d| {
|
diagnostics_on_line.max_by_key(|d| d.severity).map(|d| {
|
||||||
write!(out, "●").ok();
|
let severity = d.severity();
|
||||||
match d.severity {
|
out.push_str(severity.indicator());
|
||||||
Some(Severity::Error) => error,
|
match severity {
|
||||||
Some(Severity::Warning) | None => warning,
|
Severity::Error => error,
|
||||||
Some(Severity::Info) => info,
|
Severity::Warning => warning,
|
||||||
Some(Severity::Hint) => hint,
|
Severity::Info => info,
|
||||||
|
Severity::Hint => hint,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue