From: Mekeor Melire <mekeor@posteo.de>
To: "João Távora" <joaotavora@gmail.com>
Cc: 62687@debbugs.gnu.org
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 [thread overview]
Message-ID: <87ile4g1ou.fsf@posteo.de> (raw)
In-Reply-To: <878rf2gg5k.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]
2023-04-08 23:31 joaotavora@gmail.com:
> João Távora <joaotavora@gmail.com> writes:
>
> > Unfortunately, that commit causes Eglot to not show the
> > "ParameterInformation"'s "documenation" field. I propose to
> > show both the SigInfo- and the ParamInfo-documentation,
> > whenever possible. (To be more precise: First, the SigInfo-doc
> > should be shown, if non-nil. Then, the ParamInfo-doc should be
> > shown, if non-nil.) What do you think?
>
> I did more changes to master taking that into account. See
> e33c0a549153fa3894f3b5e9c5e42ce07a1a68c7 and tell me if there's
> any more stuff missing.
Thank you. That commit is very useful. Let's move on to the next
thing: Variable-names.
If you don't want me tamper with variable-names, then that's fine,
just let me know and I will further move to the next thing.
Otherwise, I'd suggest a coherent naming of the variables.
Specifically, I think we should derive the variable-names from the
LSP-types (e.g. "SignatureHelp" and "ParameterInformation"). A
patch is attached. Feel free to apply it or do something similar
on your own.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 62687-2023-04-09-rename-variables.patch --]
[-- Type: text/x-patch, Size: 3931 bytes --]
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 <name>(<params>)
(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))))
next prev parent reply other threads:[~2023-04-09 21:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 21:17 bug#62687: 30.0.50; Eglot (eglot--sig-info): SignatureInformation's Documentation is never shown when it's of type MarkupContent Mekeor Melire
2023-04-06 19:21 ` Mekeor Melire
2023-04-06 19:49 ` Mekeor Melire
2023-04-06 20:34 ` Mekeor Melire
2023-04-07 22:40 ` bug#62687: [PATCH] Eglot: eglot--sig-info: Show SigInfo Docs if Markup; fix regex for highlighting; etc Mekeor Melire
2023-04-07 23:49 ` João Távora
2023-04-07 23:53 ` João Távora
2023-04-08 14:35 ` Mekeor Melire
2023-04-08 19:47 ` João Távora
2023-04-08 20:44 ` Mekeor Melire
2023-04-08 21:12 ` João Távora
2023-04-08 22:31 ` João Távora
2023-04-09 21:46 ` Mekeor Melire [this message]
2023-04-10 7:14 ` João Távora
2023-04-10 20:02 ` Mekeor Melire
2023-04-11 11:16 ` João Távora
2023-04-11 11:47 ` Mekeor Melire
2023-04-11 12:56 ` João Távora
2023-04-11 13:53 ` João Távora
2023-04-11 13:59 ` Eli Zaretskii
2023-04-09 22:14 ` Mekeor Melire
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ile4g1ou.fsf@posteo.de \
--to=mekeor@posteo.de \
--cc=62687@debbugs.gnu.org \
--cc=joaotavora@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.