From: João Távora Date: Mon, 10 Jul 2023 13:06:42 +0000 (+0100) Subject: Eglot: fix eglot--sig-info again X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b56f46c9deeb782297695e39baf8f3c65c85281b;p=emacs.git Eglot: fix eglot--sig-info again See https://github.com/joaotavora/eglot/issues/1253 * lisp/progmodes/eglot.el (eglot--sig-info): Fall back to regexp technique if no parameters or poor parameter information. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 95e9a30a372..537d8cac8ae 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3197,11 +3197,25 @@ for which LSP on-type-formatting should be requested." sig (with-temp-buffer (insert siglabel) - ;; Ad-hoc attempt to parse label as () ;; 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))) + ;; Try to highlight function name only + (let (first-parlabel) + (cond ((and (cl-plusp (length parameters)) + (vectorp (setq first-parlabel + (plist-get (aref parameters 0) :label)))) + (save-excursion + (goto-char (elt first-parlabel 0)) + (skip-syntax-backward "^w") + (add-face-text-property (point-min) (point) + 'font-lock-function-name-face))) + ((save-excursion + (goto-char (point-min)) + (looking-at "\\([^(]*\\)([^)]*)")) + (add-face-text-property (match-beginning 1) (match-end 1) + 'font-lock-function-name-face)))) ;; Now to the parameters (cl-loop with active-param = (or sig-active activeParameter) @@ -3210,11 +3224,6 @@ for which LSP on-type-formatting should be requested." ((:label parlabel)) ((:documentation pardoc))) parameter - (when (zerop i) - (goto-char (elt parlabel 0)) - (skip-syntax-backward "^w") - (add-face-text-property (point-min) (point) - 'font-lock-function-name-face)) ;; ...perhaps highlight it in the formals list (when (eq i active-param) (save-excursion