all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks
@ 2024-06-04  2:51 Troy Brown
  2024-06-04  5:41 ` Felician Nemeth
  0 siblings, 1 reply; 13+ messages in thread
From: Troy Brown @ 2024-06-04  2:51 UTC (permalink / raw)
  To: 71353

[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]

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.

[-- Attachment #2: 0001-Eglot-Support-formatting-MarkedString-code-block.patch --]
[-- Type: text/x-patch, Size: 1124 bytes --]

From 4a9412478819c6cb4446d2169901cdb9152a203a Mon Sep 17 00:00:00 2001
From: Troy Brown <brownts@troybrown.dev>
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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-07-06  9:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04  2:51 bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks Troy Brown
2024-06-04  5:41 ` Felician Nemeth
2024-06-04 10:01   ` Troy Brown
2024-06-04 11:21     ` Felician Nemeth
2024-06-04 12:37       ` Troy Brown
2024-06-04 19:36         ` Felician Nemeth
2024-06-15  8:12           ` Eli Zaretskii
2024-06-15  9:37             ` João Távora
2024-06-15 12:36               ` Eli Zaretskii
2024-06-18 13:39                 ` João Távora
2024-07-01  3:28                   ` Troy Brown
2024-07-06  8:41                     ` Eli Zaretskii
2024-07-06  9:18                       ` João Távora

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.