From 42115d02bc9236adf7d1aa81029ca6a12856a160 Mon Sep 17 00:00:00 2001 From: Erasin Date: Tue, 26 Jul 2022 09:26:50 +0800 Subject: Suport diagnostic code (#3096) * add code for diagnostic. This PR provides a solution to resolve #2994. missing Code Actions for lsp * remote unused import--- helix-lsp/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'helix-lsp/src') 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, -- cgit v1.2.3-70-g09d2