unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Troy Brown <brownts@troybrown.dev>
To: 71353@debbugs.gnu.org
Subject: bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks
Date: Mon, 3 Jun 2024 22:51:07 -0400	[thread overview]
Message-ID: <CABvCZ42HctDpq=iLdEFU2vVxFLR52Gefw7ak=nijTfjFSqX46w@mail.gmail.com> (raw)

[-- 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


             reply	other threads:[~2024-06-04  2:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  2:51 Troy Brown [this message]
2024-06-04  5:41 ` bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABvCZ42HctDpq=iLdEFU2vVxFLR52Gefw7ak=nijTfjFSqX46w@mail.gmail.com' \
    --to=brownts@troybrown.dev \
    --cc=71353@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).