[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot b9e9cf3 34/45: Fix #148: complex completions work
From: |
João Távora |
Subject: |
[elpa] externals/eglot b9e9cf3 34/45: Fix #148: complex completions work when chosen from *completions* |
Date: |
Thu, 22 Nov 2018 19:15:32 -0500 (EST) |
branch: externals/eglot
commit b9e9cf35f5e4b1809f45cba563dd421b58cdee38
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Fix #148: complex completions work when chosen from *completions*
* eglot.el (eglot-completion-at-point): Make exit-function work
even if its arguments was stripped of its properties.
---
eglot.el | 60 +++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/eglot.el b/eglot.el
index f7b9c86..512e9a6 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1501,7 +1501,8 @@ is not active."
"EGLOT's `completion-at-point' function."
(let ((bounds (bounds-of-thing-at-point 'symbol))
(server (eglot--current-server-or-lose))
- (completion-capability (eglot--server-capable :completionProvider)))
+ (completion-capability (eglot--server-capable :completionProvider))
+ strings)
(when completion-capability
(list
(or (car bounds) (point))
@@ -1514,19 +1515,21 @@ is not active."
:deferred :textDocument/completion
:cancel-on-input t))
(items (if (vectorp resp) resp (plist-get resp :items))))
- (mapcar
- (jsonrpc-lambda (&rest all &key label insertText insertTextFormat
- &allow-other-keys)
- (let ((completion
- (cond ((and (eql insertTextFormat 2)
- (eglot--snippet-expansion-fn))
- (string-trim-left label))
- (t
- (or insertText (string-trim-left label))))))
- (add-text-properties 0 1 all completion)
- (put-text-property 0 1 'eglot--lsp-completion all completion)
- completion))
- items))))
+ (setq
+ strings
+ (mapcar
+ (jsonrpc-lambda (&rest all &key label insertText insertTextFormat
+ &allow-other-keys)
+ (let ((completion
+ (cond ((and (eql insertTextFormat 2)
+ (eglot--snippet-expansion-fn))
+ (string-trim-left label))
+ (t
+ (or insertText (string-trim-left label))))))
+ (add-text-properties 0 1 all completion)
+ (put-text-property 0 1 'eglot--lsp-completion all completion)
+ completion))
+ items)))))
:annotation-function
(lambda (obj)
(cl-destructuring-bind (&key detail kind insertTextFormat
@@ -1572,17 +1575,24 @@ is not active."
(cl-some #'looking-back
(mapcar #'regexp-quote
(plist-get completion-capability :triggerCharacters)))
- :exit-function (lambda (obj _status)
- (cl-destructuring-bind (&key insertTextFormat
- insertText
- &allow-other-keys)
- (text-properties-at 0 obj)
- (when-let ((fn (and (eql insertTextFormat 2)
- (eglot--snippet-expansion-fn))))
- (delete-region (- (point) (length obj)) (point))
- (funcall fn insertText))
- (eglot--signal-textDocument/didChange)
- (eglot-eldoc-function)))))))
+ :exit-function
+ (lambda (comp _status)
+ (let ((comp (if (get-text-property 0 'eglot--lsp-completion comp)
+ comp
+ ;; When selecting from the *Completions*
+ ;; buffer, `comp' won't have any properties. A
+ ;; lookup should fix that (github#148)
+ (cl-find comp strings :test #'string=))))
+ (cl-destructuring-bind (&key insertTextFormat
+ insertText
+ &allow-other-keys)
+ (text-properties-at 0 comp)
+ (when-let ((fn (and (eql insertTextFormat 2)
+ (eglot--snippet-expansion-fn))))
+ (delete-region (- (point) (length comp)) (point))
+ (funcall fn insertText))
+ (eglot--signal-textDocument/didChange)
+ (eglot-eldoc-function))))))))
(defvar eglot--highlights nil "Overlays for textDocument/documentHighlight.")
- [elpa] externals/eglot 118f966 26/45: Fix a bug when response to definitions request is a single location, (continued)
- [elpa] externals/eglot 118f966 26/45: Fix a bug when response to definitions request is a single location, João Távora, 2018/11/22
- [elpa] externals/eglot 3c180c0 19/45: Rework test macros for hopefully more stable testing, João Távora, 2018/11/22
- [elpa] externals/eglot b31ba80 35/45: Tweak solution to #125 with a hint from Fangrui Song, João Távora, 2018/11/22
- [elpa] externals/eglot fdb1941 36/45: Add support for TextEdits in completion, João Távora, 2018/11/22
- [elpa] externals/eglot d66f2eb 39/45: Treat tab characters as 1 column wide in position conversion functions, João Távora, 2018/11/22
- [elpa] externals/eglot b731db5 41/45: Add support for R's languageserver (#161), João Távora, 2018/11/22
- [elpa] externals/eglot de1728c 44/45: * eglot.el (eglot-completion-at-point): Less chatter., João Távora, 2018/11/22
- [elpa] externals/eglot fc03d7c 40/45: Fix #160: Properly delete inserted text after completion, João Távora, 2018/11/22
- [elpa] externals/eglot 604c1b0 38/45: Per #144: Format documentation of signature parameters, João Távora, 2018/11/22
- [elpa] externals/eglot 894fe5a 42/45: Fix #154: fix potential security issue fontifying LSP doc, João Távora, 2018/11/22
- [elpa] externals/eglot b9e9cf3 34/45: Fix #148: complex completions work when chosen from *completions*,
João Távora <=
- [elpa] externals/eglot 0a18dca 37/45: Fix #125: add ability to report LSP-compliant columns, João Távora, 2018/11/22
- [elpa] externals/eglot f291816 45/45: * eglot.el (Version): Bump to 1.2, João Távora, 2018/11/22
- [elpa] externals/eglot ee7f9c6 43/45: Fix #167: correctly insert TextEdit-less snippets, João Távora, 2018/11/22