[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 76d8f49 10/54: Per #50: use completionItem/resolv
From: |
João Távora |
Subject: |
[elpa] externals/eglot 76d8f49 10/54: Per #50: use completionItem/resolve more abundantly |
Date: |
Thu, 16 Apr 2020 05:31:46 -0400 (EDT) |
branch: externals/eglot
commit 76d8f49cd41f394cc602433ba79b5d18a163517f
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Per #50: use completionItem/resolve more abundantly
It was already used to resolve documentation bits of completions, but
it can also be useful to resolve snippet templates and such.
To resolve a completion, you need some part of a completion to start
with. If it has a :data field exists and the server supports
:resolveProvider, fetch the new object, otherwise use whatever we had
already.
* eglot.el (eglot-completion-at-point): Add another local
function for resolving completions.
---
eglot.el | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/eglot.el b/eglot.el
index 1f7a396..bce4ee0 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1979,6 +1979,20 @@ is not active."
(put-text-property 0 1 'eglot--lsp-item item
proxy))
proxy))
items)))))
+ resolved
+ (resolve-maybe
+ ;; Maybe completion/resolve JSON object `lsp-comp' into
+ ;; another JSON object, if at all possible. Otherwise,
+ ;; just return lsp-comp.
+ (lambda (lsp-comp)
+ (cond (resolved resolved)
+ ((and (eglot--server-capable :completionProvider
+ :resolveProvider)
+ (plist-get lsp-comp :data))
+ (setq resolved
+ (jsonrpc-request server :completionItem/resolve
+ lsp-comp :cancel-on-input t)))
+ (t lsp-comp))))
(bounds (bounds-of-thing-at-point 'symbol)))
(list
(or (car bounds) (point))
@@ -2021,13 +2035,7 @@ is not active."
(lambda (proxy)
(let* ((documentation
(let ((lsp-comp (get-text-property 0 'eglot--lsp-item proxy)))
- (or (plist-get lsp-comp :documentation)
- (and (eglot--server-capable :completionProvider
- :resolveProvider)
- (plist-get
- (jsonrpc-request server :completionItem/resolve
- lsp-comp :cancel-on-input t)
- :documentation)))))
+ (plist-get (funcall resolve-maybe lsp-comp)
:documentation)))
(formatted (and documentation
(eglot--format-markup documentation))))
(when formatted
@@ -2050,13 +2058,15 @@ is not active."
insertText
textEdit
additionalTextEdits)
- (or (get-text-property 0 'eglot--lsp-item proxy)
- ;; When selecting from the *Completions*
- ;; buffer, `proxy' won't have any properties. A
- ;; lookup should fix that (github#148)
- (get-text-property
- 0 'eglot--lsp-item
- (cl-find proxy (funcall proxies) :test #'string=)))
+ (funcall
+ resolve-maybe
+ (or (get-text-property 0 'eglot--lsp-item proxy)
+ ;; When selecting from the *Completions*
+ ;; buffer, `proxy' won't have any properties.
+ ;; A lookup should fix that (github#148)
+ (get-text-property
+ 0 'eglot--lsp-item
+ (cl-find proxy (funcall proxies) :test #'string=))))
(let ((snippet-fn (and (eql insertTextFormat 2)
(eglot--snippet-expansion-fn))))
(cond (textEdit
- [elpa] externals/eglot d5859b5 03/54: Per #319: fix race condition when company-completing quickly, (continued)
- [elpa] externals/eglot d5859b5 03/54: Per #319: fix race condition when company-completing quickly, João Távora, 2020/04/16
- [elpa] externals/eglot 576ea2e 02/54: Unbreak M-x vc-revert, which reverts preserving modes, João Távora, 2020/04/16
- [elpa] externals/eglot 32ba9d0 06/54: Expand README.md section on handling quirky servers, João Távora, 2020/04/16
- [elpa] externals/eglot 3d480d1 01/54: Fix #259 (again): fix issue with replace-buffer-contents, João Távora, 2020/04/16
- [elpa] externals/eglot 83b2acb 09/54: Support markdown for textDocument/hover (#329), João Távora, 2020/04/16
- [elpa] externals/eglot de7631d 17/54: Fix #345: set nobreak-char-display to nil in *eglot-help*, João Távora, 2020/04/16
- [elpa] externals/eglot 179a56d 13/54: Only set eglot--cached-current-server by (more aggressive) caching, João Távora, 2020/04/16
- [elpa] externals/eglot 146108a 15/54: Fix #342: Provide stable eglot-current-server helper, João Távora, 2020/04/16
- [elpa] externals/eglot 8c9078e 19/54: Fix #343: Let other imenu functions work if LSP server's doesn't, João Távora, 2020/04/16
- [elpa] externals/eglot 4bd8773 23/54: Fix #339: fail when eglot-find-* finds no references, João Távora, 2020/04/16
- [elpa] externals/eglot 76d8f49 10/54: Per #50: use completionItem/resolve more abundantly,
João Távora <=
- [elpa] externals/eglot a6fa773 25/54: Resolve compilation warnings, João Távora, 2020/04/16
- [elpa] externals/eglot b2e4687 29/54: Close #376: add metals as the language server for Scala, João Távora, 2020/04/16
- [elpa] externals/eglot 097eed5 31/54: Close #382: new eglot-confirm-server-initiated-edits defcustom, João Távora, 2020/04/16
- [elpa] externals/eglot 2ab8b59 08/54: Don't run mode hooks in eglot--format-markup, João Távora, 2020/04/16
- [elpa] externals/eglot 88311a2 12/54: Simplify "maybe"-activation, dump "server" arg, João Távora, 2020/04/16
- [elpa] externals/eglot 7f9784c 11/54: Merge -onoff proxy code into minor mode function, João Távora, 2020/04/16
- [elpa] externals/eglot 9eac9de 16/54: Fix #341: protect against empty-string insertText in completions, João Távora, 2020/04/16
- [elpa] externals/eglot b406818 07/54: Fix #326: support workspace/configuration, João Távora, 2020/04/16
- [elpa] externals/eglot ef34797 14/54: Fix #340: Don't choke on workspace/configuration with no scopeUri, João Távora, 2020/04/16
- [elpa] externals/eglot 27fb0c6 18/54: Support serverInfo of LSP 3.15.0, João Távora, 2020/04/16