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