From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mekeor Melire Newsgroups: gmane.emacs.bugs Subject: bug#62687: [PATCH] Eglot: eglot--sig-info: Show SigInfo Docs if Markup; fix regex for highlighting; etc Date: Sun, 09 Apr 2023 21:46:13 +0000 Message-ID: <87ile4g1ou.fsf@posteo.de> References: <875yaanfuv.fsf@posteo.de> <87fs9bmg1j.fsf@posteo.de> <87cz4egnqa.fsf@gmail.com> <87bkjym6ic.fsf@posteo.de> <878rf2gg5k.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13234"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62687@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 09 23:57:10 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 1pld26-0003Gs-0L for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Apr 2023 23:57:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pld20-0002CE-3O; Sun, 09 Apr 2023 17:57:04 -0400 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 1pld1y-0002C6-F9 for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 17:57:02 -0400 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 1pld1y-0002Jb-7O for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 17:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pld1x-0000zx-OD for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2023 17:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mekeor Melire Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Apr 2023 21:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62687 X-GNU-PR-Package: emacs Original-Received: via spool by 62687-submit@debbugs.gnu.org id=B62687.16810773883793 (code B ref 62687); Sun, 09 Apr 2023 21:57:01 +0000 Original-Received: (at 62687) by debbugs.gnu.org; 9 Apr 2023 21:56:28 +0000 Original-Received: from localhost ([127.0.0.1]:33898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pld1P-0000z6-Hm for submit@debbugs.gnu.org; Sun, 09 Apr 2023 17:56:27 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:39393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pld1O-0000ys-A5 for 62687@debbugs.gnu.org; Sun, 09 Apr 2023 17:56:27 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 885D4240090 for <62687@debbugs.gnu.org>; Sun, 9 Apr 2023 23:56:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1681077380; bh=6v5C1OwX9fGYJMbsSVOJvOxbZ2rhaKoI8+12IrpuAdY=; h=From:To:Cc:Subject:Date:From; b=huWeOiAOzDRGWY+Mj+FpEmid0tstnrwqCLXpZLXMJP00tGh3x7ZHPhWm5uZAA1N34 9tXDs6WkshDTjC3s0oarO1fb/iGzM4MkHcOZNtHmD8PXHNz+uqLco8FftpdqXfH8Uw pOBQQzj8VB0EftpHSEEomAhFl1EbrAX0jg8+iZgNa9WM6P6Igaan8FOJe61417/wgw XkXHMKLqULxWn6NL4T+/mcQDICYeKO/8DrXr449wwhfQgLeVnOuta669jVf6C36+vy e15pe/tSFsSdQ65TEesTPxyb7UuPgAuutiZffvCV1feyv5NpA474c8+cweNm/kfHAa r/7Q8oBE5KM9g== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PvmC76gbQz9rxD; Sun, 9 Apr 2023 23:56:19 +0200 (CEST) In-reply-to: <878rf2gg5k.fsf@gmail.com> 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:259538 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable 2023-04-08 23:31 joaotavora@gmail.com: > Jo=C3=A3o T=C3=A1vora writes: > > > Unfortunately, that commit causes Eglot to not show the=20 > > "ParameterInformation"'s "documenation" field. I propose to=20 > > show both the SigInfo- and the ParamInfo-documentation,=20 > > whenever possible. (To be more precise: First, the SigInfo-doc=20 > > should be shown, if non-nil. Then, the ParamInfo-doc should be=20 > > shown, if non-nil.) What do you think? > > I did more changes to master taking that into account. See=20 > e33c0a549153fa3894f3b5e9c5e42ce07a1a68c7 and tell me if there's=20 > any more stuff missing. Thank you. That commit is very useful. Let's move on to the next=20 thing: Variable-names. If you don't want me tamper with variable-names, then that's fine,=20 just let me know and I will further move to the next thing. Otherwise, I'd suggest a coherent naming of the variables.=20 Specifically, I think we should derive the variable-names from the=20 LSP-types (e.g. "SignatureHelp" and "ParameterInformation"). A=20 patch is attached. Feel free to apply it or do something similar=20 on your own. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=62687-2023-04-09-rename-variables.patch diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 3f00281e155..3cfdba6b550 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3118,28 +3118,30 @@ for which LSP on-type-formatting should be requested." (mapconcat #'eglot--format-markup (if (vectorp contents) contents (list contents)) "\n")) -(defun eglot--sig-info (sig &optional sig-active briefp) +(defun eglot--sig-info (sig &optional sig-help-active-par briefp) (eglot--dbind ((SignatureInformation) - ((:label siglabel)) - ((:documentation sigdoc)) parameters activeParameter) + ((:label sig-info-label)) + ((:documentation sig-info-doc)) + parameters + ((:activeParameter sig-info-active-par))) sig (with-temp-buffer - (save-excursion (insert siglabel)) + (save-excursion (insert sig-info-label)) ;; Ad-hoc attempt to parse label as () (when (looking-at "\\([^(]*\\)(\\([^)]+\\))") (add-face-text-property (match-beginning 1) (match-end 1) 'font-lock-function-name-face)) ;; Add documentation, indented so we can distinguish multiple signatures - (when-let (doc (and (not briefp) sigdoc (eglot--format-markup sigdoc))) + (when-let (doc (and (not briefp) sig-info-doc (eglot--format-markup sig-info-doc))) (goto-char (point-max)) (insert "\n" (replace-regexp-in-string "^" " " doc))) ;; Now to the parameters (cl-loop - with active-param = (or sig-active activeParameter) + with active-param = (or sig-help-active-par sig-info-active-par) for i from 0 for parameter across parameters do (eglot--dbind ((ParameterInformation) - ((:label parlabel)) - ((:documentation pardoc))) + ((:label par-label)) + ((:documentation par-doc))) parameter ;; ...perhaps highlight it in the formals list (when (and (eq i active-param)) @@ -3147,24 +3149,24 @@ for which LSP on-type-formatting should be requested." (goto-char (point-min)) (pcase-let ((`(,beg ,end) - (if (stringp parlabel) + (if (stringp par-label) (let ((case-fold-search nil)) - (and (search-forward parlabel (line-end-position) t) + (and (search-forward par-label (line-end-position) t) (list (match-beginning 0) (match-end 0)))) - (mapcar #'1+ (append parlabel nil))))) + (mapcar #'1+ (append par-label nil))))) (if (and beg end) (add-face-text-property beg end 'eldoc-highlight-function-argument))))) ;; ...and/or maybe add its doc on a line by its own. (let (fpardoc) - (when (and pardoc (not briefp) + (when (and par-doc (not briefp) (not (string-empty-p - (setq fpardoc (eglot--format-markup pardoc))))) + (setq fpardoc (eglot--format-markup par-doc))))) (insert "\n " (propertize - (if (stringp parlabel) parlabel - (apply #'substring siglabel (mapcar #'1+ parlabel))) + (if (stringp par-label) par-label + (apply #'substring sig-info-label (mapcar #'1+ par-label))) 'face (and (eq i active-param) 'eldoc-highlight-function-argument)) ": " fpardoc))))) (buffer-string)))) --=-=-=--