Skip to content

Commit f2f68a8

Browse files
committed
Per joaotavora/eglot#319: 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 microsoft/language-server-protocol#651. * eglot.el (eglot-completion-at-point): Use all-completions.
1 parent d265b29 commit f2f68a8

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

lisp/progmodes/eglot.el

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ is not active."
18891889
(list
18901890
(or (car bounds) (point))
18911891
(or (cdr bounds) (point))
1892-
(lambda (comp _pred action)
1892+
(lambda (comp pred action)
18931893
(cond
18941894
((eq action 'metadata) metadata) ; metadata
18951895
((eq action 'lambda) (member comp completions)) ; test-completion
@@ -1904,20 +1904,23 @@ is not active."
19041904
(items (if (vectorp resp) resp (plist-get resp :items))))
19051905
(setq
19061906
completions
1907-
(mapcar
1908-
(jsonrpc-lambda
1909-
(&rest all &key label insertText insertTextFormat
1910-
&allow-other-keys)
1911-
(let ((completion
1912-
(cond ((and (eql insertTextFormat 2)
1913-
(eglot--snippet-expansion-fn))
1914-
(string-trim-left label))
1915-
(t
1916-
(or insertText (string-trim-left label))))))
1917-
(put-text-property 0 1 'eglot--lsp-completion
1918-
all completion)
1919-
completion))
1920-
items))))))
1907+
(all-completions ; <-stuck with prefix-comp because <facepalm> LSP
1908+
comp
1909+
(mapcar
1910+
(jsonrpc-lambda
1911+
(&rest all &key label insertText insertTextFormat
1912+
&allow-other-keys)
1913+
(let ((completion
1914+
(cond ((and (eql insertTextFormat 2)
1915+
(eglot--snippet-expansion-fn))
1916+
(string-trim-left label))
1917+
(t
1918+
(or insertText (string-trim-left label))))))
1919+
(put-text-property 0 1 'eglot--lsp-completion
1920+
all completion)
1921+
completion))
1922+
items)
1923+
pred))))))
19211924
:annotation-function
19221925
(lambda (obj)
19231926
(eglot--dbind ((CompletionItem) detail kind insertTextFormat)

0 commit comments

Comments
 (0)