mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-24 18:36:18 +04:00
Merge 8e95c510f9
into a219d5aabb
This commit is contained in:
commit
7824958511
@ -240,10 +240,12 @@ fn render_diagnostics<F>(context: &mut RenderContext, write: F)
|
|||||||
counts
|
counts
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let icons = context.editor.config().diagnostic_icons;
|
||||||
|
|
||||||
if warnings > 0 {
|
if warnings > 0 {
|
||||||
write(
|
write(
|
||||||
context,
|
context,
|
||||||
"●".to_string(),
|
icons.warning.to_string(),
|
||||||
Some(context.editor.theme.get("warning")),
|
Some(context.editor.theme.get("warning")),
|
||||||
);
|
);
|
||||||
write(context, format!(" {} ", warnings), None);
|
write(context, format!(" {} ", warnings), None);
|
||||||
@ -252,7 +254,7 @@ fn render_diagnostics<F>(context: &mut RenderContext, write: F)
|
|||||||
if errors > 0 {
|
if errors > 0 {
|
||||||
write(
|
write(
|
||||||
context,
|
context,
|
||||||
"●".to_string(),
|
icons.error.to_string(),
|
||||||
Some(context.editor.theme.get("error")),
|
Some(context.editor.theme.get("error")),
|
||||||
);
|
);
|
||||||
write(context, format!(" {} ", errors), None);
|
write(context, format!(" {} ", errors), None);
|
||||||
|
@ -13,6 +13,27 @@ pub enum DiagnosticFilter {
|
|||||||
Enable(Severity),
|
Enable(Severity),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The icon (character) to use for each [`Diagnostic`] level.
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Copy, Clone, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
|
#[serde(default, deny_unknown_fields)]
|
||||||
|
pub struct DiagnosticIcons {
|
||||||
|
pub error: char,
|
||||||
|
pub warning: char,
|
||||||
|
pub info: char,
|
||||||
|
pub hint: char,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for DiagnosticIcons {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
error: '●',
|
||||||
|
warning: '●',
|
||||||
|
info: '●',
|
||||||
|
hint: '●',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for DiagnosticFilter {
|
impl<'de> Deserialize<'de> for DiagnosticFilter {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
annotations::diagnostics::{DiagnosticFilter, InlineDiagnosticsConfig},
|
annotations::diagnostics::{DiagnosticFilter, DiagnosticIcons, InlineDiagnosticsConfig},
|
||||||
document::{
|
document::{
|
||||||
DocumentOpenError, DocumentSavedEventFuture, DocumentSavedEventResult, Mode, SavePoint,
|
DocumentOpenError, DocumentSavedEventFuture, DocumentSavedEventResult, Mode, SavePoint,
|
||||||
},
|
},
|
||||||
@ -345,6 +345,7 @@ pub struct Config {
|
|||||||
/// Display diagnostic below the line they occur.
|
/// Display diagnostic below the line they occur.
|
||||||
pub inline_diagnostics: InlineDiagnosticsConfig,
|
pub inline_diagnostics: InlineDiagnosticsConfig,
|
||||||
pub end_of_line_diagnostics: DiagnosticFilter,
|
pub end_of_line_diagnostics: DiagnosticFilter,
|
||||||
|
pub diagnostic_icons: DiagnosticIcons,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)]
|
||||||
@ -982,6 +983,7 @@ fn default() -> Self {
|
|||||||
jump_label_alphabet: ('a'..='z').collect(),
|
jump_label_alphabet: ('a'..='z').collect(),
|
||||||
inline_diagnostics: InlineDiagnosticsConfig::default(),
|
inline_diagnostics: InlineDiagnosticsConfig::default(),
|
||||||
end_of_line_diagnostics: DiagnosticFilter::Disable,
|
end_of_line_diagnostics: DiagnosticFilter::Disable,
|
||||||
|
diagnostic_icons: DiagnosticIcons::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,16 +46,19 @@ pub fn width(self, view: &View, doc: &Document) -> usize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn diagnostic<'doc>(
|
pub fn diagnostic<'doc>(
|
||||||
_editor: &'doc Editor,
|
editor: &'doc Editor,
|
||||||
doc: &'doc Document,
|
doc: &'doc Document,
|
||||||
_view: &View,
|
_view: &View,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
_is_focused: bool,
|
_is_focused: bool,
|
||||||
) -> GutterFn<'doc> {
|
) -> GutterFn<'doc> {
|
||||||
let warning = theme.get("warning");
|
let icons = &editor.config().diagnostic_icons;
|
||||||
let error = theme.get("error");
|
|
||||||
let info = theme.get("info");
|
let warning = (theme.get("warning"), icons.warning);
|
||||||
let hint = theme.get("hint");
|
let error = (theme.get("error"), icons.error);
|
||||||
|
let info = (theme.get("info"), icons.info);
|
||||||
|
let hint = (theme.get("hint"), icons.hint);
|
||||||
|
|
||||||
let diagnostics = &doc.diagnostics;
|
let diagnostics = &doc.diagnostics;
|
||||||
|
|
||||||
Box::new(
|
Box::new(
|
||||||
@ -74,13 +77,14 @@ pub fn diagnostic<'doc>(
|
|||||||
.any(|ls| ls.id() == d.provider)
|
.any(|ls| ls.id() == d.provider)
|
||||||
});
|
});
|
||||||
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 (style, indicator) = match d.severity {
|
||||||
match d.severity {
|
|
||||||
Some(Severity::Error) => error,
|
Some(Severity::Error) => error,
|
||||||
Some(Severity::Warning) | None => warning,
|
Some(Severity::Warning) | None => warning,
|
||||||
Some(Severity::Info) => info,
|
Some(Severity::Info) => info,
|
||||||
Some(Severity::Hint) => hint,
|
Some(Severity::Hint) => hint,
|
||||||
}
|
};
|
||||||
|
out.push(indicator);
|
||||||
|
style
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user