From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#61373: Eglot patch: add customization to prefer plaintext for :hover Date: Wed, 8 Feb 2023 16:33:16 -0500 Message-ID: <75664907-6B17-43AC-B372-724DA6E7BA42@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_3560A896-AD34-4C96-9547-1284CFCE2766" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15528"; mail-complaints-to="usenet@ciao.gmane.io" To: 61373@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 08 22:34:32 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pPs5I-0003jh-3P for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Feb 2023 22:34:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPs4q-0003CX-Ld; Wed, 08 Feb 2023 16:34:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPs4p-0003CH-0V for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 16:34:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPs4o-0001vW-Nz for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 16:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pPs4o-0004qH-5p for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 16:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Feb 2023 21:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61373 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167589201518565 (code B ref -1); Wed, 08 Feb 2023 21:34:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Feb 2023 21:33:35 +0000 Original-Received: from localhost ([127.0.0.1]:56814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPs4M-0004pM-Or for submit@debbugs.gnu.org; Wed, 08 Feb 2023 16:33:35 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:34750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPs4K-0004pC-66 for submit@debbugs.gnu.org; Wed, 08 Feb 2023 16:33:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPs4H-00038r-QP for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 16:33:30 -0500 Original-Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPs4G-0000WB-18 for bug-gnu-emacs@gnu.org; Wed, 08 Feb 2023 16:33:29 -0500 Original-Received: by mail-qt1-x82b.google.com with SMTP id v17so22579019qto.3 for ; Wed, 08 Feb 2023 13:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=PXL1J212wwT4ZFrNdkSFe5/DgHX9BALD0WrlJ/FGCKs=; b=jNwpvluuNZqETPBcWppDOu+zhFkAkRJRrPBHJS7dRxMUpbSsmuRHKkUyRu2a4xFn7k EoLC6OqiVoeSrqSbAlv0gOPpI+Zr1aJjhupTb3xKC2hhvVFhHv/B9VvB68RJOTrigkYI uEONJbMGXIksKcPqJjVvuPMHB6+EY/MBTGM9LvsYwG58lufmExgkRQe29zKPE/DyESCi dqttmDBBGttu+hqO8NyXV/+DrUfxBf5LqPjbN73Q3f99+w466WqVWz//hVnwXCH0CYSQ XYVXtakSgoV28xww2N8bMB3hRq+fuya81YGF/T91ryQGkFklfwWgFMXYU9bOp4qEMkQH PwyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PXL1J212wwT4ZFrNdkSFe5/DgHX9BALD0WrlJ/FGCKs=; b=rOUjwkj7MdEcfApkgOk4jrAJ6b8hSZMmGn3QkPlcGVv/QnHIpB8iNDzPZcnJAL3Koi av46Zgh3rGhgHuTtIfTmJV+HyQGuvntsdDk2HXX35eKwQX63Y1gAXEZ+P6sjYBFXE4gn SRo/vNl3b5whbMRFOcVu76ZiPSoYl0DfeLo4DuXSo8zIhH/Sqhd23f1em87HmLYqllwv e/hmkcHHsL0y47SK57Q25wvnqVqR19iZEL/b4Dpx21W1X/2hIjGddf3YfN9EnNEr0vDq vn5Jcrh5al3CsjqxyH6SXsmpaAbEchYTzZ2/5PX/RATn86JwM/jn4ZyJOTWJIk2quDw+ XqWQ== X-Gm-Message-State: AO0yUKW0CLDGF+5EwyGZlRD8uuK2+mXHVEPOJJbmsoNOqmpEPFktHBNp XZkDEIDBKhkAe26mDUM6ougyvRJZXXE= X-Google-Smtp-Source: AK7set+W2DtTMlApguNPTpy/5BC2FHf2Z7KJ+tDoZQr4g1IvcHU17yxqHUaSqsGNMiWNBqHVCgm38A== X-Received: by 2002:a05:622a:c7:b0:3ba:1398:c68d with SMTP id p7-20020a05622a00c700b003ba1398c68dmr14827094qtw.16.1675891999594; Wed, 08 Feb 2023 13:33:19 -0800 (PST) Original-Received: from smtpclient.apple ([131.183.131.75]) by smtp.gmail.com with ESMTPSA id s25-20020a05620a16b900b0072ed644bb0dsm11542467qkj.97.2023.02.08.13.33.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2023 13:33:18 -0800 (PST) X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=jdtsmith@gmail.com; helo=mail-qt1-x82b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:255164 Archived-At: --Apple-Mail=_3560A896-AD34-4C96-9547-1284CFCE2766 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Some LSP servers badly mangle their responses to :hover into markdown = that gfm-viewmode cannot render. See this discussion = , for example.=20 The attached patch adds a new custom option `eglot-prefer-plaintext=E2=80=99= 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=E2=80=9D). = Luckily the plaintext docstrings of most packages are very nicely = formatted.=20 --Apple-Mail=_3560A896-AD34-4C96-9547-1284CFCE2766 Content-Type: multipart/mixed; boundary="Apple-Mail=_D7B22108-EAC4-4882-8426-BB0C24CB1C27" --Apple-Mail=_D7B22108-EAC4-4882-8426-BB0C24CB1C27 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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=E2=80=99 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=E2=80=9D).  Luckily = the plaintext docstrings of most packages are very nicely = formatted. 

= --Apple-Mail=_D7B22108-EAC4-4882-8426-BB0C24CB1C27 Content-Disposition: attachment; filename=eglot_plaintext.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="eglot_plaintext.patch" Content-Transfer-Encoding: 7bit --- 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 --Apple-Mail=_D7B22108-EAC4-4882-8426-BB0C24CB1C27 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii

--Apple-Mail=_D7B22108-EAC4-4882-8426-BB0C24CB1C27-- --Apple-Mail=_3560A896-AD34-4C96-9547-1284CFCE2766--