Subject: bug#71353: closed (Re: bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 06 Jul 2024 09:19:02 +0000

Your bug report

#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71353: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71353
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks
From: João Távora <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked], Troy Brown <[email-masked]>, [email-masked]
Date: Sat, 06 Jul 2024 10:18:46 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Eli Zaretskii <[email-masked]> writes:

> João, would you please install your patch?

Done in the emacs-30 branch.  Closing this bug.

Subject: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks
From: Troy Brown <[email-masked]>
To: [email-masked]
Date: Mon, 3 Jun 2024 22:51:07 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

It appears that eglot--format-markup only supports MarkedString for
string literals and MarkupContent.  This causes markup provided by the
server as a MarkedString code-block to be formatted using the major
mode.  This happens because the MarkedString code-block uses the
"language" field to designate the type of markup.
eglot--format-markup is only looking for the "kind" field found in
MarkupContent.  The following is an example of a hover response from
an LSP server using a MarkedString code-block to provide a description
in "plaintext".

[jsonrpc] e[13:34:28.888] --> textDocument/hover[25]
{"jsonrpc":"2.0","id":25,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///home/troy/repos/crates/gtkada_24.0.0_80c56171/src/gtkada.gpr"},"position":{"line":70,"character":12}}}
[jsonrpc] e[13:34:29.033] <-- textDocument/hover[25]
{"jsonrpc":"2.0","id":25,"result":{"contents":[{"language":"plaintext","value":"This
package specifies the compilation options used when building an
executable or a library for a project. Most of the options should be
set in one of Compiler, Binder or Linker packages, but there are some
general options that should be defined in this package."}]}}

The following patch will format MarkedString code-blocks for markdown
and plaintext while using the major mode to format any other language.
From 4a9412478819c6cb4446d2169901cdb9152a203a Mon Sep 17 00:00:00 2001
From: Troy Brown <[email-masked]>
Date: Mon, 3 Jun 2024 22:19:24 -0400
Subject: [PATCH] Eglot: Support formatting MarkedString code-block

* lisp/progmodes/eglot.el (eglot--format-markup): Add support
for MarkedString code-block.

Copyright-paperwork-exempt: yes
---
 lisp/progmodes/eglot.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 5ccae5210fe..3a44acdb75b 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1862,7 +1862,8 @@ eglot--format-markup
   (pcase-let ((`(,string ,mode)
                (if (stringp markup) (list markup 'gfm-view-mode)
                  (list (plist-get markup :value)
-                       (pcase (plist-get markup :kind)
+                       (pcase (or (plist-get markup :kind)
+                                  (plist-get markup :language))
                          ("markdown" 'gfm-view-mode)
                          ("plaintext" 'text-mode)
                          (_ major-mode))))))
-- 
2.37.1