From: Brian Leung Date: Mon, 1 Feb 2021 01:28:49 +0000 (-0800) Subject: Support activeparameter property for signatureinformation X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~175 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bdf57d5d4e888a6a7b4066b87497da8a8d9e36de;p=emacs.git Support activeparameter property for signatureinformation 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 * 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 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 51ed1c49a96..27094a2bd50 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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 () (when (looking-at "\\([^(]+\\)(\\([^)]+\\))") (setq params-start (match-beginning 2) params-end (match-end 2))