diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 10b6c0cc2ca..42989b9e73e 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3120,6 +3120,7 @@ for which LSP on-type-formatting should be requested." (eglot--dbind ((SignatureInformation) label documentation parameters activeParameter) sig (with-temp-buffer + ;; Insert SignatureInformation label (save-excursion (insert label)) (let ((active-param (or activeParameter sig-help-active-param)) params-start params-end) @@ -3128,44 +3129,40 @@ for which LSP on-type-formatting should be requested." (setq params-start (match-beginning 2) params-end (match-end 2)) (add-face-text-property (match-beginning 1) (match-end 1) 'font-lock-function-name-face)) - ;; Decide whether to add one-line-summary to signature line - (when (and (stringp documentation) - (string-match "[[:space:]]*\\([^.\r\n]+[.]?\\)" - documentation)) - (setq documentation (match-string 1 documentation)) - (unless (string-prefix-p (string-trim documentation) label) - (goto-char (point-max)) - (insert ": " (eglot--format-markup documentation)))) + ;; Insert SignatureInformation documentation + (goto-char (point-max)) + (unless (null documentation) + (insert "\n\n" + (if (stringp documentation) + (string-trim documentation) + (eglot--format-markup documentation)))) ;; Decide what to do with the active parameter... (when (and active-param (< -1 active-param (length parameters))) (eglot--dbind ((ParameterInformation) label documentation) (aref parameters active-param) ;; ...perhaps highlight it in the formals list - (when params-start - (goto-char params-start) - (pcase-let - ((`(,beg ,end) - (if (stringp label) - (let ((case-fold-search nil)) - (and (re-search-forward - (concat "\\<" (regexp-quote label) "\\>") - params-end t) - (list (match-beginning 0) (match-end 0)))) - (mapcar #'1+ (append 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. + (pcase-let + ((`(,beg . ,end) + (if (stringp label) + (if params-start + (let ((case-fold-search nil)) + (goto-char params-start) + (and (re-search-forward + (regexp-quote label) + params-end t) + (cons (match-beginning 0) (match-end 0))))) + (mapcar #'1+ label)))) + (if (and beg end) + (add-face-text-property + beg end + 'eldoc-highlight-function-argument))) + ;; ...and maybe add its doc on a line by its own. (when documentation (goto-char (point-max)) - (insert "\n" - (propertize - (if (stringp label) - label - (apply #'buffer-substring (mapcar #'1+ label))) - 'face 'eldoc-highlight-function-argument) - ": " (eglot--format-markup documentation)))))) + (insert "\n\n" + (if (stringp documentation) + (string-trim documentation) + (eglot--format-markup documentation))))))) (buffer-string)))) (defun eglot-signature-eldoc-function (cb) @@ -3183,7 +3180,7 @@ for which LSP on-type-formatting should be requested." (aref signatures (or activeSignature 0))))) (if (not active-sig) (funcall cb nil) (funcall cb - (mapconcat #'eglot--sig-info signatures "\n") + (mapconcat #'eglot--sig-info signatures "\n\n") :echo (eglot--sig-info active-sig t activeParameter)))))) :deferred :textDocument/signatureHelp)) t))