mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
Add editor.diagnostics-symbol config option
This commit is contained in:
parent
91e642ce50
commit
705f35db3c
@ -240,10 +240,12 @@ fn render_diagnostics<F>(context: &mut RenderContext, write: F)
|
||||
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 @@ fn render_diagnostics<F>(context: &mut RenderContext, write: F)
|
||||
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 @@ fn render_workspace_diagnostics<F>(context: &mut RenderContext, write: F)
|
||||
}
|
||||
counts
|
||||
});
|
||||
let sym = &context.editor.config().diagnostics_symbol;
|
||||
|
||||
if warnings > 0 || errors > 0 {
|
||||
write(context, " W ".into(), None);
|
||||
@ -285,7 +288,7 @@ fn render_workspace_diagnostics<F>(context: &mut RenderContext, write: F)
|
||||
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 @@ fn render_workspace_diagnostics<F>(context: &mut RenderContext, write: F)
|
||||
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 @@ fn default() -> Self {
|
||||
jump_label_alphabet: ('a'..='z').collect(),
|
||||
inline_diagnostics: InlineDiagnosticsConfig::default(),
|
||||
end_of_line_diagnostics: DiagnosticFilter::Disable,
|
||||
diagnostics_symbol: '●',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub fn width(self, view: &View, doc: &Document) -> usize {
|
||||
}
|
||||
|
||||
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…
Reference in New Issue
Block a user