Skip to content

Commit

Permalink
Show diagnostic codes for LSP diagnostics (helix-editor#6378)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
  • Loading branch information
2 people authored and Schuyler Mortimer committed Jul 10, 2024
1 parent 7774094 commit b9c2410
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
};

use helix_core::{
diagnostic::NumberOrString,
graphemes::{
ensure_grapheme_boundary_next_byte, next_grapheme_boundary, prev_grapheme_boundary,
},
Expand All @@ -30,7 +31,7 @@ use helix_view::{
};
use std::{mem::take, num::NonZeroUsize, path::PathBuf, rc::Rc, sync::Arc};

use tui::buffer::Buffer as Surface;
use tui::{buffer::Buffer as Surface, text::Span};

use super::statusline;
use super::{document::LineDecoration, lsp::SignatureHelp};
Expand Down Expand Up @@ -684,6 +685,14 @@ impl EditorView {
});
let text = Text::styled(&diagnostic.message, style);
lines.extend(text.lines);
let code = diagnostic.code.as_ref().map(|x| match x {
NumberOrString::Number(n) => format!("({n})"),
NumberOrString::String(s) => format!("({s})"),
});
if let Some(code) = code {
let span = Span::styled(code, style);
lines.push(span.into());
}
}

let paragraph = Paragraph::new(lines)
Expand Down

0 comments on commit b9c2410

Please sign in to comment.