@@ -56,6 +56,8 @@ impl EditorView {
5656 // TODO: this seems to prevent setting style later
5757 // surface.set_style(viewport, theme.get("ui.background"));
5858
59+ self.render_diagnostics(&view.doc, area, surface, theme, is_focused);
60+
5961 let area = Rect::new(
6062 viewport.x,
6163 viewport.y + viewport.height.saturating_sub(1),
@@ -166,7 +168,8 @@ impl EditorView {
166168
167169 // ugh,interleave highlight spans with diagnostic spans
168170 let is_diagnostic = view.doc.diagnostics.iter().any(|diagnostic| {
169− diagnostic.range.0 <= char_index && diagnostic.range.1 > char_index
171+ diagnostic.range.start <= char_index
172+ && diagnostic.range.end > char_index
170173 });
171174
172175 let style = if is_diagnostic {
@@ -316,6 +319,60 @@ impl EditorView {
316319 }
317320 }
318321
322+ pub fn render_diagnostics(
323+ &self,
324+ doc: &Document,
325+ viewport: Rect,
326+ surface: &mut Surface,
327+ theme: &Theme,
328+ is_focused: bool,
329+ ) {
330+ use helix_core::diagnostic::Severity;
331+ use tui::{
332+ layout::Alignment,
333+ text::Text,
334+ widgets::{Paragraph, Widget},
335+ };
336+
337+ let cursor = doc.selection().cursor();
338+ let line = doc.text().char_to_line(cursor);
339+
340+ let diagnostics = doc.diagnostics.iter().filter(|diagnostic| {
341+ diagnostic.range.start <= cursor && diagnostic.range.end >= cursor
342+ });
343+
344+ let warning: Style = theme.get("warning");
345+ let error: Style = theme.get("error");
346+ let info: Style = theme.get("info");
347+ let hint: Style = theme.get("hint");
348+
349+ // Vec::with_capacity(diagnostics.len()); // rough estimate
350+ let mut lines = Vec::new();
351+ for diagnostic in diagnostics {
352+ let text = Text::styled(
353+ &diagnostic.message,
354+ match diagnostic.severity {
355+ Some(Severity::Error) => error,
356+ Some(Severity::Warning) | None => warning,
357+ Some(Severity::Info) => info,
358+ Some(Severity::Hint) => hint,
359+ },
360+ );
361+ lines.extend(text.lines);
362+ }
363+
364+ let paragraph = Paragraph::new(lines).alignment(Alignment::Right);
365+ paragraph.render(
366+ Rect::new(
367+ viewport.x + viewport.width - 80 - 1,
368+ viewport.y as u16 + 1,
369+ 80,
370+ 15,
371+ ),
372+ surface,
373+ );
374+ }
375+
319376 pub fn render_statusline(
320377 &self,
321378 doc: &Document,