diff --git a/helix-core/src/diagnostic.rs b/helix-core/src/diagnostic.rs
index 210ad639..48a68dc0 100644
--- a/helix-core/src/diagnostic.rs
+++ b/helix-core/src/diagnostic.rs
@@ -23,6 +23,12 @@ pub struct Range {
     pub end: usize,
 }
 
+#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
+pub enum NumberOrString {
+    Number(i32),
+    String(String),
+}
+
 /// Corresponds to [`lsp_types::Diagnostic`](https://docs.rs/lsp-types/0.91.0/lsp_types/struct.Diagnostic.html)
 #[derive(Debug, Clone)]
 pub struct Diagnostic {
@@ -30,4 +36,5 @@ pub struct Diagnostic {
     pub line: usize,
     pub message: String,
     pub severity: Option<Severity>,
+    pub code: Option<NumberOrString>,
 }
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index 6a5f9d5c..b6e36423 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -58,7 +58,7 @@ pub enum OffsetEncoding {
 
 pub mod util {
     use super::*;
-    use helix_core::{Range, Rope, Transaction};
+    use helix_core::{diagnostic::NumberOrString, Range, Rope, Transaction};
 
     /// Converts a diagnostic in the document to [`lsp::Diagnostic`].
     ///
@@ -78,11 +78,19 @@ pub mod util {
             Error => lsp::DiagnosticSeverity::ERROR,
         });
 
+        let code = match diag.code.clone() {
+            Some(x) => match x {
+                NumberOrString::Number(x) => Some(lsp::NumberOrString::Number(x)),
+                NumberOrString::String(x) => Some(lsp::NumberOrString::String(x)),
+            },
+            None => None,
+        };
+
         // TODO: add support for Diagnostic.data
         lsp::Diagnostic::new(
             range_to_lsp_range(doc, range, offset_encoding),
             severity,
-            None,
+            code,
             None,
             diag.message.to_owned(),
             None,
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 3ee5481f..737b1cad 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -2,6 +2,7 @@ use arc_swap::{access::Map, ArcSwap};
 use futures_util::Stream;
 use helix_core::{
     config::{default_syntax_loader, user_syntax_loader},
+    diagnostic::NumberOrString,
     pos_at_coords, syntax, Selection,
 };
 use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
@@ -556,12 +557,24 @@ impl Application {
                                         }
                                     };
 
+                                    let code = match diagnostic.code.clone() {
+                                        Some(x) => match x {
+                                            lsp::NumberOrString::Number(x) => {
+                                                Some(NumberOrString::Number(x))
+                                            }
+                                            lsp::NumberOrString::String(x) => {
+                                                Some(NumberOrString::String(x))
+                                            }
+                                        },
+                                        None => None,
+                                    };
+
                                     Some(Diagnostic {
                                         range: Range { start, end },
                                         line: diagnostic.range.start.line as usize,
                                         message: diagnostic.message.clone(),
                                         severity,
-                                        // code
+                                        code,
                                         // source
                                     })
                                 })