]> git.eshelyaron.com Git - emacs.git/commitdiff
Support activeparameter property for signatureinformation
authorBrian Leung <bkleung89@gmail.com>
Mon, 1 Feb 2021 01:28:49 +0000 (17:28 -0800)
committerJoão Távora <joaotavora@gmail.com>
Mon, 1 Feb 2021 10:29:35 +0000 (10:29 +0000)
SignatureInformation.activeParameter is new in version 3.16.0 of the
protocol.  When non-nil, it is used in place of
SignatureHelp.activeParameter.  The latter was deemed insufficient in
languages where multiple signatures for the same function may exist
with arbitrary order of parameters, like Python.

Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot--lsp-interface-alist): Add
SignatureInformation.activeParameter.

* eglot.el (eglot--sig-info): Prioritize
SignatureInformation.activeParameter over
SignatureHelp.activeParameter.

GitHub-reference: close https://github.com/joaotavora/eglot/issues/605

lisp/progmodes/eglot.el

index 51ed1c49a96dfc1acac7f65aa8bd8d90054e288d..27094a2bd505d1ce196e5e910e2b096d42adb482 100644 (file)
@@ -276,7 +276,7 @@ let the buffer grow forever."
       (ShowMessageParams (:type :message))
       (ShowMessageRequestParams (:type :message) (:actions))
       (SignatureHelp (:signatures) (:activeSignature :activeParameter))
-      (SignatureInformation (:label) (:documentation :parameters))
+      (SignatureInformation (:label) (:documentation :parameters :activeParameter))
       (SymbolInformation (:name :kind :location)
                          (:deprecated :containerName))
       (DocumentSymbol (:name :range :selectionRange :kind)
@@ -2265,14 +2265,15 @@ is not active."
                          (if (vectorp contents) contents (list contents)) "\n")))
     (when (or heading (cl-plusp (length body))) (concat heading body))))
 
-(defun eglot--sig-info (sigs active-sig active-param)
+(defun eglot--sig-info (sigs active-sig sig-help-active-param)
   (cl-loop
    for (sig . moresigs) on (append sigs nil) for i from 0
    concat
-   (eglot--dbind ((SignatureInformation) label documentation parameters) sig
+   (eglot--dbind ((SignatureInformation) label documentation parameters activeParameter) sig
      (with-temp-buffer
        (save-excursion (insert label))
-       (let (params-start params-end)
+       (let ((active-param (or activeParameter sig-help-active-param))
+             params-start params-end)
          ;; Ad-hoc attempt to parse label as <name>(<params>)
          (when (looking-at "\\([^(]+\\)(\\([^)]+\\))")
            (setq params-start (match-beginning 2) params-end (match-end 2))