Add editor.diagnostics-symbol config option

pull/11461/head
ataractic 4 months ago
parent 91e642ce50
commit 705f35db3c
No known key found for this signature in database
GPG Key ID: B78DC77B6F1ACF19

@ -240,10 +240,12 @@ where
counts
});
let sym = &context.editor.config().diagnostics_symbol;
if warnings > 0 {
write(
context,
"●".to_string(),
sym.to_string(),
Some(context.editor.theme.get("warning")),
);
write(context, format!(" {} ", warnings), None);
@ -252,7 +254,7 @@ where
if errors > 0 {
write(
context,
"●".to_string(),
sym.to_string(),
Some(context.editor.theme.get("error")),
);
write(context, format!(" {} ", errors), None);
@ -277,6 +279,7 @@ where
}
counts
});
let sym = &context.editor.config().diagnostics_symbol;
if warnings > 0 || errors > 0 {
write(context, " W ".into(), None);
@ -285,7 +288,7 @@ where
if warnings > 0 {
write(
context,
"●".to_string(),
sym.to_string(),
Some(context.editor.theme.get("warning")),
);
write(context, format!(" {} ", warnings), None);
@ -294,7 +297,7 @@ where
if errors > 0 {
write(
context,
"●".to_string(),
sym.to_string(),
Some(context.editor.theme.get("error")),
);
write(context, format!(" {} ", errors), None);

@ -345,6 +345,7 @@ pub struct Config {
/// Display diagnostic below the line they occur.
pub inline_diagnostics: InlineDiagnosticsConfig,
pub end_of_line_diagnostics: DiagnosticFilter,
pub diagnostics_symbol: char,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
@ -979,6 +980,7 @@ impl Default for Config {
jump_label_alphabet: ('a'..='z').collect(),
inline_diagnostics: InlineDiagnosticsConfig::default(),
end_of_line_diagnostics: DiagnosticFilter::Disable,
diagnostics_symbol: '',
}
}
}

@ -46,7 +46,7 @@ impl GutterType {
}
pub fn diagnostic<'doc>(
_editor: &'doc Editor,
editor: &'doc Editor,
doc: &'doc Document,
_view: &View,
theme: &Theme,
@ -57,6 +57,7 @@ pub fn diagnostic<'doc>(
let info = theme.get("info");
let hint = theme.get("hint");
let diagnostics = &doc.diagnostics;
let sym = editor.config().diagnostics_symbol;
Box::new(
move |line: usize, _selected: bool, first_visual_line: bool, out: &mut String| {
@ -74,7 +75,7 @@ pub fn diagnostic<'doc>(
.any(|ls| ls.id() == d.provider)
});
diagnostics_on_line.max_by_key(|d| d.severity).map(|d| {
write!(out, "●").ok();
write!(out, "{}", sym).ok();
match d.severity {
Some(Severity::Error) => error,
Some(Severity::Warning) | None => warning,

Loading…
Cancel
Save