unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61373: Eglot patch: add customization to prefer plaintext for :hover
@ 2023-02-08 21:33 JD Smith
       [not found] ` <handler.61373.B.167589201518565.ack@debbugs.gnu.org>
  2023-03-23 21:25 ` bug#61373: Eglot patch: add customization to prefer plaintext for :hover João Távora
  0 siblings, 2 replies; 3+ messages in thread
From: JD Smith @ 2023-02-08 21:33 UTC (permalink / raw)
  To: 61373

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

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

end of thread, other threads:[~2023-03-23 21:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 21:33 bug#61373: Eglot patch: add customization to prefer plaintext for :hover JD Smith
     [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

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).