Eglot: fix broken indentation of eglot--sig-info

* lisp/progmodes/eglot.el (eglot--sig-info): Fix.
This commit is contained in:
João Távora 2023-07-01 22:49:24 +01:00
parent f6e6d6c730
commit a371e1def7

View file

@ -3196,51 +3196,51 @@ for which LSP on-type-formatting should be requested."
((:documentation sigdoc)) parameters activeParameter)
sig
(with-temp-buffer
(insert siglabel)
;; Ad-hoc attempt to parse label as <name>(<params>)
;; Add documentation, indented so we can distinguish multiple signatures
(when-let (doc (and (not briefp) sigdoc (eglot--format-markup sigdoc)))
(goto-char (point-max))
(insert "\n" (replace-regexp-in-string "^" " " doc)))
;; Now to the parameters
(cl-loop
with active-param = (or sig-active activeParameter)
for i from 0 for parameter across parameters do
(eglot--dbind ((ParameterInformation)
((:label parlabel))
((:documentation pardoc)))
parameter
(when (zerop i)
(goto-char (elt parlabel 0))
(search-backward "(" nil t)
(add-face-text-property (point-min) (point)
'font-lock-function-name-face))
;; ...perhaps highlight it in the formals list
(when (= i active-param)
(save-excursion
(goto-char (point-min))
(pcase-let
((`(,beg ,end)
(if (stringp parlabel)
(let ((case-fold-search nil))
(and (search-forward parlabel (line-end-position) t)
(list (match-beginning 0) (match-end 0))))
(mapcar #'1+ (append parlabel 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)
(not (string-empty-p
(setq fpardoc (eglot--format-markup pardoc)))))
(insert "\n "
(propertize
(if (stringp parlabel) parlabel
(apply #'substring siglabel (mapcar #'1+ parlabel)))
'face (and (eq i active-param) 'eldoc-highlight-function-argument))
": " fpardoc)))))
(insert siglabel)
;; Ad-hoc attempt to parse label as <name>(<params>)
;; Add documentation, indented so we can distinguish multiple signatures
(when-let (doc (and (not briefp) sigdoc (eglot--format-markup sigdoc)))
(goto-char (point-max))
(insert "\n" (replace-regexp-in-string "^" " " doc)))
;; Now to the parameters
(cl-loop
with active-param = (or sig-active activeParameter)
for i from 0 for parameter across parameters do
(eglot--dbind ((ParameterInformation)
((:label parlabel))
((:documentation pardoc)))
parameter
(when (zerop i)
(goto-char (elt parlabel 0))
(search-backward "(" nil t)
(add-face-text-property (point-min) (point)
'font-lock-function-name-face))
;; ...perhaps highlight it in the formals list
(when (= i active-param)
(save-excursion
(goto-char (point-min))
(pcase-let
((`(,beg ,end)
(if (stringp parlabel)
(let ((case-fold-search nil))
(and (search-forward parlabel (line-end-position) t)
(list (match-beginning 0) (match-end 0))))
(mapcar #'1+ (append parlabel 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)
(not (string-empty-p
(setq fpardoc (eglot--format-markup pardoc)))))
(insert "\n "
(propertize
(if (stringp parlabel) parlabel
(apply #'substring siglabel (mapcar #'1+ parlabel)))
'face (and (eq i active-param) 'eldoc-highlight-function-argument))
": " fpardoc)))))
(buffer-string))))
(defun eglot-signature-eldoc-function (cb)