branch: externals/eglot
commit 1f2b0241ca24d78edbd146d17daef6a0e6b2e4f3
Author: Brian Leung <[email protected]>
Commit: João Távora <[email protected]>
Close #605: 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 <[email protected]>
* eglot.el (eglot--lsp-interface-alist): Add
SignatureInformation.activeParameter.
* eglot.el (eglot--sig-info): Prioritize
SignatureInformation.activeParameter over
SignatureHelp.activeParameter.
---
eglot.el | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/eglot.el b/eglot.el
index 51ed1c4..27094a2 100644
--- a/eglot.el
+++ b/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 <name>(<params>)
(when (looking-at "\\([^(]+\\)(\\([^)]+\\))")
(setq params-start (match-beginning 2) params-end (match-end 2))