on master help sign in
Show diagnostic codes for LSP diagnostics (#6378)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commit05ee673197c5f882aec0e894cc45e574bb2e46fe authorFrancesc Elies <elies@posteo.net> dateTue 21 Mar 2023, 23:15 (4 years ago) parent346ddd4
1 file changed+10−1
helix-term/src/ui/editor.rs+10−1
helix-term/src/ui/editor.rs+10−1
@@ -11,6 +11,7 @@ use crate::{
1111};
1212
1313use helix_core::{
14+ diagnostic::NumberOrString,
1415 graphemes::{
1516 ensure_grapheme_boundary_next_byte, next_grapheme_boundary, prev_grapheme_boundary,
1617 },
@@ -30,7 +31,7 @@ use helix_view::{
3031};
3132use std::{mem::take, num::NonZeroUsize, path::PathBuf, rc::Rc, sync::Arc};
3233
33−use tui::buffer::Buffer as Surface;
34+use tui::{buffer::Buffer as Surface, text::Span};
3435
3536use super::statusline;
3637use super::{document::LineDecoration, lsp::SignatureHelp};
@@ -684,6 +685,14 @@ impl EditorView {
684685 });
685686 let text = Text::styled(&diagnostic.message, style);
686687 lines.extend(text.lines);
688+ let code = diagnostic.code.as_ref().map(|x| match x {
689+ NumberOrString::Number(n) => format!("({n})"),
690+ NumberOrString::String(s) => format!("({s})"),
691+ });
692+ if let Some(code) = code {
693+ let span = Span::styled(code, style);
694+ lines.push(span.into());
695+ }
687696 }
688697
689698 let paragraph = Paragraph::new(lines)