]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: fix eglot--sig-info again
authorJoão Távora <joaotavora@gmail.com>
Mon, 10 Jul 2023 13:06:42 +0000 (14:06 +0100)
committerJoão Távora <joaotavora@gmail.com>
Mon, 10 Jul 2023 13:06:42 +0000 (14:06 +0100)
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.

lisp/progmodes/eglot.el

index 95e9a30a37206e5f093a83fbfa674bb70a1099cd..537d8cac8aed25e079dc90bca0c56c98f777ace4 100644 (file)
@@ -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 <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)))
+      ;; 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