Repository: autozimu/LanguageClient-neovim (language: rust)

Issue:
Display diagnostics source in diagnostics output
For ALE, one can use

    let g:ale_echo_msg_format = '%linter%: %s'

To prepend the linter to the diagnostics output.
Is there a similar mechanism for this?
I was unable to see how diagnosticsDisplay could be configured to allow this.


Discussion / hints:
No.

I'm not interested in implementing this myself. PR is welcome.

Fix patch:
diff --git a/src/language_server_protocol.rs b/src/language_server_protocol.rs
index b72d6550a..d007e571c 100644
--- a/src/language_server_protocol.rs
+++ b/src/language_server_protocol.rs
@@ -3327,9 +3327,13 @@ impl LanguageClient {
         if let Some(diag_list) = diag_list {
             for diag in diag_list {
                 if viewport.overlaps(diag.range) {
+                    let mut explanation = diag.message.clone();
+                    if let Some(source) = &diag.source {
+                        explanation = format!("{}: {}\n", source, explanation);
+                    }
                     virtual_texts.push(VirtualText {
                         line: diag.range.start.line,
-                        text: diag.message.replace("\n", "  ").clone(),
+                        text: explanation.replace("\n", "  "),
                         hl_group: diagnostics_display
                             .get(&(diag.severity.unwrap_or(DiagnosticSeverity::Hint) as u64))
                             .ok_or_else(|| anyhow!("Failed to get display"))?
@@ -3715,6 +3719,9 @@ impl LanguageClient {
         let root_uri = root.to_url()?;
 
         let mut explanation = diag.message;
+        if let Some(source) = diag.source {
+            explanation = format!("{}: {}\n", source, explanation);
+        }
         if let Some(related_information) = diag.related_information {
             explanation = format!("{}\n", explanation);
             for ri in related_information {


Test patch: