@@ -4,7 +4,7 @@ use lsp_types::request::DocumentDiagnosticRequest;
44use lsp_types:: {
55 Diagnostic , DiagnosticSeverity , DiagnosticTag , DocumentDiagnosticParams ,
66 DocumentDiagnosticReport , DocumentDiagnosticReportResult , FullDocumentDiagnosticReport ,
7- NumberOrString , Range , RelatedFullDocumentDiagnosticReport , Url ,
7+ NumberOrString , Range , RelatedFullDocumentDiagnosticReport ,
88} ;
99
1010use crate :: document:: ToRangeExt ;
@@ -22,7 +22,7 @@ impl RequestHandler for DocumentDiagnosticRequestHandler {
2222}
2323
2424impl BackgroundDocumentRequestHandler for DocumentDiagnosticRequestHandler {
25- fn document_url ( params : & DocumentDiagnosticParams ) -> Cow < Url > {
25+ fn document_url ( params : & DocumentDiagnosticParams ) -> Cow < lsp_types :: Url > {
2626 Cow :: Borrowed ( & params. text_document . uri )
2727 }
2828
@@ -105,12 +105,23 @@ fn to_lsp_diagnostic(
105105 } )
106106 . filter ( |mapped_tags| !mapped_tags. is_empty ( ) ) ;
107107
108+ let code_description = diagnostic
109+ . id ( )
110+ . is_lint ( )
111+ . then ( || {
112+ Some ( lsp_types:: CodeDescription {
113+ href : lsp_types:: Url :: parse ( & format ! ( "https://ty.dev/rules#{}" , diagnostic. id( ) ) )
114+ . ok ( ) ?,
115+ } )
116+ } )
117+ . flatten ( ) ;
118+
108119 Diagnostic {
109120 range,
110121 severity : Some ( severity) ,
111122 tags,
112123 code : Some ( NumberOrString :: String ( diagnostic. id ( ) . to_string ( ) ) ) ,
113- code_description : None ,
124+ code_description,
114125 source : Some ( "ty" . into ( ) ) ,
115126 message : diagnostic. concise_message ( ) . to_string ( ) ,
116127 related_information : None ,
0 commit comments