]> git.eshelyaron.com Git - emacs.git/commitdiff
Always filter completions client-side by prefix
authorJoão Távora <joaotavora@gmail.com>
Wed, 16 Oct 2019 08:49:09 +0000 (09:49 +0100)
committerJoão Távora <joaotavora@gmail.com>
Wed, 16 Oct 2019 10:49:01 +0000 (11:49 +0100)
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

index f757a8ac4ff149ecc1f78d00267565be12161c85..ce3705a3a360d9b605f88b32ffce913282246766 100644 (file)
@@ -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 <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)