aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-core/src/diagnostic.rs8
-rw-r--r--helix-core/src/lib.rs2
-rw-r--r--helix-term/src/application.rs16
-rw-r--r--helix-term/src/ui/editor.rs20
-rw-r--r--helix-view/src/theme.rs3
5 files changed, 43 insertions, 6 deletions
diff --git a/helix-core/src/diagnostic.rs b/helix-core/src/diagnostic.rs
index 96ed6746..c1a3b4c1 100644
--- a/helix-core/src/diagnostic.rs
+++ b/helix-core/src/diagnostic.rs
@@ -1,7 +1,15 @@
use crate::Range;
+pub enum Severity {
+ Error,
+ Warning,
+ Info,
+ Hint,
+}
+
pub struct Diagnostic {
pub range: (usize, usize),
pub line: usize,
pub message: String,
+ pub severity: Option<Severity>,
}
diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs
index 89b82c4e..81a35f10 100644
--- a/helix-core/src/lib.rs
+++ b/helix-core/src/lib.rs
@@ -1,6 +1,6 @@
#![allow(unused)]
pub mod comment;
-mod diagnostic;
+pub mod diagnostic;
pub mod graphemes;
mod history;
pub mod indent;
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 583d8fc8..24b5317b 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -139,15 +139,25 @@ impl Application {
.diagnostics
.into_iter()
.map(|diagnostic| {
- use helix_lsp::util::lsp_pos_to_pos;
+ use helix_core::diagnostic::Severity::*;
+ use helix_core::{diagnostic::Severity, Diagnostic};
+ use helix_lsp::{lsp, util::lsp_pos_to_pos};
+ use lsp::DiagnosticSeverity;
let start = lsp_pos_to_pos(doc, diagnostic.range.start);
let end = lsp_pos_to_pos(doc, diagnostic.range.end);
- helix_core::Diagnostic {
+ Diagnostic {
range: (start, end),
line: diagnostic.range.start.line as usize,
message: diagnostic.message,
- // severity
+ severity: diagnostic.severity.map(
+ |severity| match severity {
+ DiagnosticSeverity::Error => Error,
+ DiagnosticSeverity::Warning => Warning,
+ DiagnosticSeverity::Information => Info,
+ DiagnosticSeverity::Hint => Hint,
+ },
+ ),
// code
// source
}
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 7a5e4aa5..ae48950f 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -283,10 +283,26 @@ impl EditorView {
let style: Style = theme.get("ui.linenr");
let warning: Style = theme.get("warning");
+ let error: Style = theme.get("error");
+ let info: Style = theme.get("info");
+ let hint: Style = theme.get("hint");
+
let last_line = view.last_line();
for (i, line) in (view.first_line..last_line).enumerate() {
- if view.doc.diagnostics.iter().any(|d| d.line == line) {
- surface.set_stringn(viewport.x - OFFSET, viewport.y + i as u16, "●", 1, warning);
+ use helix_core::diagnostic::Severity;
+ if let Some(diagnostic) = view.doc.diagnostics.iter().find(|d| d.line == line) {
+ surface.set_stringn(
+ viewport.x - OFFSET,
+ viewport.y + i as u16,
+ "●",
+ 1,
+ match diagnostic.severity {
+ Some(Severity::Error) => error,
+ Some(Severity::Warning) | None => warning,
+ Some(Severity::Info) => info,
+ Some(Severity::Hint) => hint,
+ },
+ );
}
surface.set_stringn(
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs
index ad15f6f2..0efd329c 100644
--- a/helix-view/src/theme.rs
+++ b/helix-view/src/theme.rs
@@ -160,6 +160,9 @@ impl Default for Theme {
"ui.popup" => Style::default().bg(Color::Rgb(40, 23, 51)), // revolver
"warning" => Style::default().fg(Color::Rgb(255, 205, 28)),
+ "error" => Style::default().fg(Color::Rgb(244, 120, 104)),
+ "info" => Style::default().fg(Color::Rgb(111, 68, 240)),
+ "hint" => Style::default().fg(Color::Rgb(204, 204, 204)),
};
let scopes = mapping.keys().map(ToString::to_string).collect();