Skip to content

Commit

Permalink
Per joaotavora/eglot#319: always filter completions client-side by pr…
Browse files Browse the repository at this point in the history
…efix

Prefix completion is all we get in LSP because there are some servers
that send *all* completions everytime.  This is horrible, but it's the
currently defined behaviour.  See
microsoft/language-server-protocol#651.

* eglot.el (eglot-completion-at-point): Use all-completions.
  • Loading branch information
joaotavora committed Oct 16, 2019
1 parent d265b29 commit f2f68a8
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -1889,7 +1889,7 @@ is not active."
(list
(or (car bounds) (point))
(or (cdr bounds) (point))
(lambda (comp _pred action)
(lambda (comp pred action)
(cond
((eq action 'metadata) metadata) ; metadata
((eq action 'lambda) (member comp completions)) ; test-completion
Expand All @@ -1904,20 +1904,23 @@ is not active."
(items (if (vectorp resp) resp (plist-get resp :items))))
(setq
completions
(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))))))
(put-text-property 0 1 'eglot--lsp-completion
all completion)
completion))
items))))))
(all-completions ; <-stuck with prefix-comp because <facepalm> LSP
comp
(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))))))
(put-text-property 0 1 'eglot--lsp-completion
all completion)
completion))
items)
pred))))))
:annotation-function
(lambda (obj)
(eglot--dbind ((CompletionItem) detail kind insertTextFormat)
Expand Down

0 comments on commit f2f68a8

Please sign in to comment.