]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: improve heuristic to highlight function names in signatures
authorJoão Távora <joaotavora@gmail.com>
Sat, 1 Jul 2023 21:46:43 +0000 (22:46 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sat, 1 Jul 2023 21:49:48 +0000 (22:49 +0100)
* lisp/progmodes/eglot.el (eglot--sig-info): Rework.

See https://github.com/joaotavora/eglot/discussions/1251.

lisp/progmodes/eglot.el

index e2478f2dde3cf2bd7c59ada329d844857a2a1ed8..94ca5c942452721a54359e50d37f4974d489f0a1 100644 (file)
@@ -3196,11 +3196,8 @@ for which LSP on-type-formatting should be requested."
                  ((:documentation sigdoc)) parameters activeParameter)
       sig
     (with-temp-buffer
-      (save-excursion (insert siglabel))
-      ;; 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))
+        (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))
@@ -3213,8 +3210,13 @@ for which LSP on-type-formatting should be requested."
                         ((: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 (and (eq i active-param))
+           (when (= i active-param)
              (save-excursion
                (goto-char (point-min))
                (pcase-let