Skip to content

Commit

Permalink
Fix #190: sort candidates immediately after fetching them.
Browse files Browse the repository at this point in the history
The :display-sort-function property in capf functions (vs the
'display-sort-function metadata property) doesn't appear to anything,
as pointed out by Felicián Németh.

* eglot.el (eglot-completion-at-point): Move location of sort function.
  • Loading branch information
joaotavora committed Dec 22, 2018
1 parent 2f0e51a commit e43399b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,11 @@ is not active."
(add-text-properties 0 1 all completion)
(put-text-property 0 1 'eglot--lsp-completion all completion)
completion))
items))))
(sort items
(lambda (a b)
(string-lessp
(or (plist-get a :sortText) "")
(or (plist-get b :sortText) ""))))))))
:annotation-function
(lambda (obj)
(eglot--dbind ((CompletionItem) detail kind insertTextFormat)
Expand All @@ -1852,12 +1856,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
Expand Down

0 comments on commit e43399b

Please sign in to comment.