From 705f35db3c40d489828c5066b29ff78db08ad1f4 Mon Sep 17 00:00:00 2001 From: ataractic Date: Sat, 10 Aug 2024 19:18:22 +0200 Subject: [PATCH] Add editor.diagnostics-symbol config option --- helix-term/src/ui/statusline.rs | 11 +++++++---- helix-view/src/editor.rs | 2 ++ helix-view/src/gutter.rs | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 7437cbd07..aeee5ef3e 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -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); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 1708b3b4e..5550ee6b0 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -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: '●', } } } diff --git a/helix-view/src/gutter.rs b/helix-view/src/gutter.rs index 36f719f79..fee6e0efd 100644 --- a/helix-view/src/gutter.rs +++ b/helix-view/src/gutter.rs @@ -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,