aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorFrancesc Elies2023-03-21 22:15:01 +0000
committerGitHub2023-03-21 22:15:01 +0000
commit05ee673197c5f882aec0e894cc45e574bb2e46fe (patch)
treee26c71ae31a6d05400fd4ed67862f14ff80e78f7 /helix-term
parent346ddd473512ed6e9a81e1fa9d42717a37afcf76 (diff)
Show diagnostic codes for LSP diagnostics (#6378)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 7c22df74..0b6ab046 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -11,6 +11,7 @@ use crate::{
};
use helix_core::{
+ diagnostic::NumberOrString,
graphemes::{
ensure_grapheme_boundary_next_byte, next_grapheme_boundary, prev_grapheme_boundary,
},
@@ -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};
@@ -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)