on master help sign in
Use diagnostic.severity to distinguish between error colors.
9dcfe25Blaž Hrastnik
helix-core/src/diagnostic.rs+8
@@ -1,7 +1,15 @@
1use crate::Range;
1use crate::Range;
2
2
3+pub enum Severity {
4+ Error,
5+ Warning,
6+ Info,
7+ Hint,
8+}
9+
3pub struct Diagnostic {
10pub struct Diagnostic {
4 pub range: (usize, usize),
11 pub range: (usize, usize),
5 pub line: usize,
12 pub line: usize,
6 pub message: String,
13 pub message: String,
14+ pub severity: Option<Severity>,
7}
15}
helix-core/src/lib.rs+1−1
@@ -1,6 +1,6 @@
1#![allow(unused)]
1#![allow(unused)]
2pub mod comment;
2pub mod comment;
3−mod diagnostic;
3+pub mod diagnostic;
4pub mod graphemes;
4pub mod graphemes;
5mod history;
5mod history;
6pub mod indent;
6pub mod indent;
helix-term/src/application.rs+13−3
@@ -139,15 +139,25 @@ impl Application {
139 .diagnostics
139 .diagnostics
140 .into_iter()
140 .into_iter()
141 .map(|diagnostic| {
141 .map(|diagnostic| {
142+ use helix_core::diagnostic::Severity::*;
143+ use helix_core::{diagnostic::Severity, Diagnostic};
142− use helix_lsp::util::lsp_pos_to_pos;
144+ use helix_lsp::{lsp, util::lsp_pos_to_pos};
145+ use lsp::DiagnosticSeverity;
143 let start = lsp_pos_to_pos(doc, diagnostic.range.start);
146 let start = lsp_pos_to_pos(doc, diagnostic.range.start);
144 let end = lsp_pos_to_pos(doc, diagnostic.range.end);
147 let end = lsp_pos_to_pos(doc, diagnostic.range.end);
145
148
146− helix_core::Diagnostic {
149+ Diagnostic {
147 range: (start, end),
150 range: (start, end),
148 line: diagnostic.range.start.line as usize,
151 line: diagnostic.range.start.line as usize,
149 message: diagnostic.message,
152 message: diagnostic.message,
153+ severity: diagnostic.severity.map(
150− // severity
154+ |severity| match severity {
155+ DiagnosticSeverity::Error => Error,
156+ DiagnosticSeverity::Warning => Warning,
157+ DiagnosticSeverity::Information => Info,
158+ DiagnosticSeverity::Hint => Hint,
159+ },
160+ ),
151 // code
161 // code
152 // source
162 // source
153 }
163 }
helix-term/src/ui/editor.rs+18−2
@@ -283,10 +283,26 @@ impl EditorView {
283
283
284 let style: Style = theme.get("ui.linenr");
284 let style: Style = theme.get("ui.linenr");
285 let warning: Style = theme.get("warning");
285 let warning: Style = theme.get("warning");
286+ let error: Style = theme.get("error");
287+ let info: Style = theme.get("info");
288+ let hint: Style = theme.get("hint");
289+
286 let last_line = view.last_line();
290 let last_line = view.last_line();
287 for (i, line) in (view.first_line..last_line).enumerate() {
291 for (i, line) in (view.first_line..last_line).enumerate() {
292+ use helix_core::diagnostic::Severity;
288− if view.doc.diagnostics.iter().any(|d| d.line == line) {
293+ if let Some(diagnostic) = view.doc.diagnostics.iter().find(|d| d.line == line) {
289− surface.set_stringn(viewport.x - OFFSET, viewport.y + i as u16, "●", 1, warning);
294+ surface.set_stringn(
295+ viewport.x - OFFSET,
296+ viewport.y + i as u16,
297+ "●",
298+ 1,
299+ match diagnostic.severity {
300+ Some(Severity::Error) => error,
301+ Some(Severity::Warning) | None => warning,
302+ Some(Severity::Info) => info,
303+ Some(Severity::Hint) => hint,
304+ },
305+ );
290 }
306 }
291
307
292 surface.set_stringn(
308 surface.set_stringn(
helix-view/src/theme.rs+3
@@ -160,6 +160,9 @@ impl Default for Theme {
160 "ui.popup" => Style::default().bg(Color::Rgb(40, 23, 51)), // revolver
160 "ui.popup" => Style::default().bg(Color::Rgb(40, 23, 51)), // revolver
161
161
162 "warning" => Style::default().fg(Color::Rgb(255, 205, 28)),
162 "warning" => Style::default().fg(Color::Rgb(255, 205, 28)),
163+ "error" => Style::default().fg(Color::Rgb(244, 120, 104)),
164+ "info" => Style::default().fg(Color::Rgb(111, 68, 240)),
165+ "hint" => Style::default().fg(Color::Rgb(204, 204, 204)),
163 };
166 };
164
167
165 let scopes = mapping.keys().map(ToString::to_string).collect();
168 let scopes = mapping.keys().map(ToString::to_string).collect();