[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot d167c80 15/22: Fix #190: actually make completion
From: |
João Távora |
Subject: |
[elpa] externals/eglot d167c80 15/22: Fix #190: actually make completion sorting work |
Date: |
Sat, 5 Jan 2019 09:31:04 -0500 (EST) |
branch: externals/eglot
commit d167c8014d76d06c9448fff2feba3d12b9c665f9
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Fix #190: actually make completion sorting work
* eglot.el (eglot-completion-at-point): Complicate severely.
---
eglot.el | 66 +++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 36 insertions(+), 30 deletions(-)
diff --git a/eglot.el b/eglot.el
index 5861b05..d60fc07 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1806,37 +1806,49 @@ is not active."
(defun eglot-completion-at-point ()
"EGLOT's `completion-at-point' function."
- (let ((bounds (bounds-of-thing-at-point 'symbol))
+ (let* ((bounds (bounds-of-thing-at-point 'symbol))
(server (eglot--current-server-or-lose))
(completion-capability (eglot--server-capable :completionProvider))
+ (sort-completions (lambda (completions)
+ (sort completions
+ (lambda (a b)
+ (string-lessp
+ (or (get-text-property 0 :sortText a) "")
+ (or (get-text-property 0 :sortText b)
""))))))
+ (metadata `(metadata . ((display-sort-function . ,sort-completions))))
strings)
(when completion-capability
(list
(or (car bounds) (point))
(or (cdr bounds) (point))
- (completion-table-dynamic
- (lambda (_ignored)
- (let* ((resp (jsonrpc-request server
- :textDocument/completion
- (eglot--CompletionParams)
- :deferred :textDocument/completion
- :cancel-on-input t))
- (items (if (vectorp resp) resp (plist-get resp :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)))))
+ (lambda (string pred action)
+ (if (eq action 'metadata) metadata
+ (funcall
+ (completion-table-dynamic
+ (lambda (_ignored)
+ (let* ((resp (jsonrpc-request server
+ :textDocument/completion
+ (eglot--CompletionParams)
+ :deferred :textDocument/completion
+ :cancel-on-input t))
+ (items (if (vectorp resp) resp (plist-get resp :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)))))
+ string pred action)))
:annotation-function
(lambda (obj)
(eglot--dbind ((CompletionItem) detail kind insertTextFormat)
@@ -1854,12 +1866,6 @@ is not active."
(and (eql insertTextFormat 2)
(eglot--snippet-expansion-fn)
" (snippet)"))))))
- :display-sort-function
- (lambda (items)
- (sort items (lambda (a b)
- (string-lessp
- (or (get-text-property 0 :sortText a) "")
- (or (get-text-property 0 :sortText b) "")))))
:company-doc-buffer
(lambda (obj)
(let* ((documentation
- [elpa] externals/eglot updated (23accee -> 35597d2), João Távora, 2019/01/05
- [elpa] externals/eglot cc5ef6c 02/22: Apply eglot--format-markup to signature documentation, João Távora, 2019/01/05
- [elpa] externals/eglot d77b447 04/22: Adjust active param highlighting in first line of signature (2/3), João Távora, 2019/01/05
- [elpa] externals/eglot ef95839 05/22: Adjust active param highlighting in first line of signature (3/3), João Távora, 2019/01/05
- [elpa] externals/eglot 64c7605 03/22: Adjust active param highlighting in first line of signature (1/3), João Távora, 2019/01/05
- [elpa] externals/eglot e8b9cbf 16/22: Slightly simplify eglot-completion-at-point, João Távora, 2019/01/05
- [elpa] externals/eglot d5521e9 12/22: Remove workaround for company bug that has been fixed, João Távora, 2019/01/05
- [elpa] externals/eglot d167c80 15/22: Fix #190: actually make completion sorting work,
João Távora <=
- [elpa] externals/eglot 476feb8 07/22: Add edebug specs to destructuring macros, João Távora, 2019/01/05
- [elpa] externals/eglot b8a8901 09/22: Fix #187: be more careful when making xref summaries, João Távora, 2019/01/05
- [elpa] externals/eglot 2f0e51a 13/22: Per #188: use gfm-view-mode, João Távora, 2019/01/05
- [elpa] externals/eglot b393c48 14/22: Fix previous commit where workaround had been removed, João Távora, 2019/01/05
- [elpa] externals/eglot 64da240 19/22: Fix #196: run connection hooks with proper dir-locals, João Távora, 2019/01/05
- [elpa] externals/eglot af9dcad 10/22: Take over Flymake and Eldoc completely while managing buffers, João Távora, 2019/01/05
- [elpa] externals/eglot 5b9a164 01/22: Per #180: frame lsp-mode.el comparison as historical even more evidently, João Távora, 2019/01/05
- [elpa] externals/eglot 7b0d845 17/22: Close #195: remove a hard dependency on flymake-mode, João Távora, 2019/01/05
- [elpa] externals/eglot 923cbbe 08/22: Don't make bogus responses to client/(Un)RegisterCapability, João Távora, 2019/01/05
- [elpa] externals/eglot 85711cc 11/22: * eglot.el (Package-Requires): Require jsonrpc 1.0.7., João Távora, 2019/01/05