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

* bug#61373: Acknowledgement (Eglot patch: add customization to prefer plaintext for :hover)
       [not found] ` <handler.61373.B.167589201518565.ack@debbugs.gnu.org>
@ 2023-02-15  2:37   ` JD Smith
  0 siblings, 0 replies; 3+ messages in thread
From: JD Smith @ 2023-02-15  2:37 UTC (permalink / raw)
  To: 61373; +Cc: joaotavora


Copying in João.







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

* bug#61373: Eglot patch: add customization to prefer plaintext for :hover
  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-03-23 21:25 ` João Távora
  1 sibling, 0 replies; 3+ messages in thread
From: João Távora @ 2023-03-23 21:25 UTC (permalink / raw)
  To: JD Smith; +Cc: 61373-done

JD Smith <jdtsmith@gmail.com> writes:

> Some LSP servers badly mangle their responses to :hover into markdown that gfm-viewmode cannot render.  See this
> discussion, 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.

Hi,

I've pushed your patch to master:

commit 4566a0c6b825a18e6c065da0543b8b942b7db8df (HEAD -> master, origin/master, origin/HEAD)
Author: JD Smith <jdtsmith@gmail.com>
Date:   Thu Mar 23 17:43:52 2023 +0000

    Eglot: let user opt-in to plaintext LSP docs (bug#61373)

    * lisp/progmodes/eglot.el
    (eglot-prefer-plaintext): New variable.
    (eglot-client-capabilities): Use it.

    Copyright-paperwork-exempt: yes

I opted noted not to describe eglot-prefer-plaintext in the manual,
because I think this option should ultimately live in ElDoc, not in
Eglot.  Properly supporting markdown rendering in Eldoc is hard though,
so there's little reason not to push this simple workaround.

Closing this bug.  See also bug#61072 and bug#62029 for more discussion.

João





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