Repository: tweag/nickel (rust)

Issue:
The LSP doesn't show the details of type errors anymore in the diagnostics
**Describe the bug**
When I edit a file with a static type error in it, the diagnostic shown in my editor is not very informative, because it doesn't show the notes of the diagnostic which include the type and whatnot. I thus just get "incompatible types", which is unhelpful. This is a regression wrt to latest stable (1.4.1), which does show the full diagnostic (see below).

**To Reproduce**
Input `5 : String` in your editor:

![image](https://github.com/tweag/nickel/assets/6530104/f724c48e-625a-428a-b0dc-40826657bb6c)

**Expected behavior**

This is the behavior in current stable (1.4.1), and expected one:

![image](https://github.com/tweag/nickel/assets/6530104/3a21727e-67c4-4d89-9bd9-3b3a66c69e3f)

**Environment**
 - Version of the code: 71a84b3ed9226379b24aa55cc6e1149fd8ec212d


Pull request description:
Reinstate notes in in-editor diagnostics
Fixes #1850 

Patch:
diff --git a/lsp/nls/src/diagnostic.rs b/lsp/nls/src/diagnostic.rs
index b0e1bb92..ab298bd4 100644
--- a/lsp/nls/src/diagnostic.rs
+++ b/lsp/nls/src/diagnostic.rs
@@ -123,11 +123,16 @@ impl DiagnosticCompat for SerializableDiagnostic {
                 .next()
                 .map(|label| lsp_types::Range::from_codespan(&label.file_id, &label.range, files))
             {
+                let message = if diagnostic.notes.is_empty() {
+                    diagnostic.message.clone()
+                } else {
+                    format!("{}\n{}", diagnostic.message, diagnostic.notes.join("\n"))
+                };
                 diagnostics.push(SerializableDiagnostic {
                     range,
                     severity,
                     code: code.clone(),
-                    message: diagnostic.message,
+                    message,
                     related_information: Some(
                         cross_file_labels
                             .map(|label| DiagnosticRelatedInformation {


Test patch:
diff --git a/lsp/nls/tests/inputs/diagnostics-typecheck.ncl b/lsp/nls/tests/inputs/diagnostics-typecheck.ncl
new file mode 100644
index 00000000..045b40b1
--- /dev/null
+++ b/lsp/nls/tests/inputs/diagnostics-typecheck.ncl
@@ -0,0 +1,3 @@
+### /diagnostics.ncl
+5 : String
+### diagnostic = ["file:///diagnostics.ncl"]
diff --git a/lsp/nls/tests/snapshots/main__lsp__nls__tests__inputs__diagnostics-typecheck.ncl.snap b/lsp/nls/tests/snapshots/main__lsp__nls__tests__inputs__diagnostics-typecheck.ncl.snap
new file mode 100644
index 00000000..d16fe3d4
--- /dev/null
+++ b/lsp/nls/tests/snapshots/main__lsp__nls__tests__inputs__diagnostics-typecheck.ncl.snap
@@ -0,0 +1,9 @@
+---
+source: lsp/nls/tests/main.rs
+expression: output
+---
+(file:///diagnostics.ncl, 0:0-0:1: incompatible types
+Expected an expression of type `String`
+Found an expression of type `Number`
+These types are not compatible)
+(file:///diagnostics.ncl, 0:0-0:1: this expression)