unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: JD Smith <jdtsmith@gmail.com>
To: 61373@debbugs.gnu.org
Subject: bug#61373: Eglot patch: add customization to prefer plaintext for :hover
Date: Wed, 8 Feb 2023 16:33:16 -0500	[thread overview]
Message-ID: <75664907-6B17-43AC-B372-724DA6E7BA42@gmail.com> (raw)

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

Some LSP servers badly mangle their responses to :hover into markdown that gfm-viewmode cannot render.  See this discussion <https://github.com/joaotavora/eglot/discussions/1039>, for example. 

The attached patch adds a new custom option `eglot-prefer-plaintext’ which configures the server to use plaintext for :hover responses, even if Emacs could in principle handle markdown.  Unfortunately, the popular Python LSP server in question (pyright) is not interested in improvement to its generated markdown (since it "works in VS-Code”).  Luckily the plaintext docstrings of most packages are very nicely formatted. 




[-- Attachment #2.1: Type: text/html, Size: 979 bytes --]

[-- Attachment #2.2: eglot_plaintext.patch --]
[-- Type: application/octet-stream, Size: 1040 bytes --]

--- eglot.el~	2023-02-08 12:45:57.000000000 -0500
+++ eglot.el	2023-02-08 12:48:26.000000000 -0500
@@ -369,6 +369,10 @@
   "If non-nil, activate Eglot in cross-referenced non-project files."
   :type 'boolean)
 
+(defcustom eglot-prefer-plaintext nil
+  "If non-nil, always request plaintext responses to hover requests."
+  :type 'boolean)
+
 (defcustom eglot-menu-string "eglot"
   "String displayed in mode line when Eglot is active."
   :type 'string)
@@ -734,7 +738,8 @@
                                     :contextSupport t)
              :hover              (list :dynamicRegistration :json-false
                                        :contentFormat
-                                       (if (fboundp 'gfm-view-mode)
+                                       (if (and (not eglot-prefer-plaintext)
+						(fboundp 'gfm-view-mode))
                                            ["markdown" "plaintext"]
                                          ["plaintext"]))
              :signatureHelp      (list :dynamicRegistration :json-false

[-- Attachment #2.3: Type: text/html, Size: 239 bytes --]

             reply	other threads:[~2023-02-08 21:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 21:33 JD Smith [this message]
     [not found] ` <handler.61373.B.167589201518565.ack@debbugs.gnu.org>
2023-02-15  2:37   ` bug#61373: Acknowledgement (Eglot patch: add customization to prefer plaintext for :hover) JD Smith
2023-03-23 21:25 ` bug#61373: Eglot patch: add customization to prefer plaintext for :hover 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=75664907-6B17-43AC-B372-724DA6E7BA42@gmail.com \
    --to=jdtsmith@gmail.com \
    --cc=61373@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).