From ca9649c6b39abe75e90822936b214d6d4eb10ec3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 16 Oct 2019 09:49:09 +0100 Subject: [PATCH] Always filter completions client-side by prefix 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 https://github.com/microsoft/language-server-protocol/issues/651. * eglot.el (eglot-completion-at-point): Use all-completions. GitHub-reference: per https://github.com/joaotavora/eglot/issues/319 --- lisp/progmodes/eglot.el | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index f757a8ac4ff..ce3705a3a36 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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 @@ -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 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) -- 2.39.2