diff options
author | João Távora <joaotavora@gmail.com> | 2023-03-29 19:30:04 +0100 |
---|---|---|
committer | João Távora <joaotavora@gmail.com> | 2023-04-02 23:40:46 +0100 |
commit | ad1efe5e675216e1f1f342fc9d48018fac718b5e (patch) | |
tree | e9bfb4aaeb3e1e40fb58024201286d53bd6c00fa /etc | |
parent | d00e05daa96700860dbb9dc6527105e464ffb960 (diff) | |
download | emacs-ad1efe5e675216e1f1f342fc9d48018fac718b5e.tar.gz |
Eglot: improve caching in eglot-completion-at-point
When answering the :textDocument/completion request, LSP servers
provide a :isIncomplete flag in the response, which allows Eglot to
know if "further typing should result in recomputing [the completions]
list.
If :isIncomplete is false (i.e. the full set was returned), Eglot
caches the response in a global variable eglot--capf-cache that
persists for the duration of the "completion session", taken to be the
interval between two calls to completion-in-region-mode.
If the cache has been set, and Eglot detects that "further typing" has
happened, it is safe to use the cache instead of making a request to
the server.
Thus eglot--capf-cache-flush, added to completion-in-region-mode-hook,
is used to flush this cache. Since the popular Company completion
package doesn't use completion-in-region-mode, eglot--capf-cache-flush
is also added to its company-after-completion-hook.
* lisp/progmodes/eglot.el (eglot--managed-mode): Set
'completion-in-region-mode-hook and company-after-completion-hook.
(eglot--capf-cache): New variable.
(eglot--capf-cache-flush): New function.
(eglot-completion-at-point): Rework.
* etc/EGLOT-NEWS: Update.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/EGLOT-NEWS | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/etc/EGLOT-NEWS b/etc/EGLOT-NEWS index dd04e677285..09772a1e71a 100644 --- a/etc/EGLOT-NEWS +++ b/etc/EGLOT-NEWS @@ -18,6 +18,28 @@ to look up issue github#1234, go to https://github.com/joaotavora/eglot/issues/1234. +* Changes in upcoming Eglot 1.14 + +** Faster, more responsive completion + +Eglot takes advantage of LSP's "isIncomplete" flag in responses to +completion requests to drive new completion-caching mechanism for the +duration of each completion session. Once a full set of completions +is obtained for a given position, the server needn't be contacted in +many scenarios, resulting in significantly less communication +overhead. This works with the popular Company package and stock +completion-at-point interfaces. + +A variable 'eglot-cache-session-completions', t by default, controls +this. The mechanism was tested with ccls, jdtls, pylsp, golsp and +clangd. Notably, the C/C++ language server Clangd version 15 has a +bug in its "isIcomplete" flag (it is fixed in later versions). If you +run into problems, disable this mechanism like so: + +(add-hook 'c-common-mode-hook + (lambda () (setq-local eglot-cache-session-completions nil))) + + * Changes in Eglot 1.13 (15/03/2023) ** ELPA installations on Emacs 26.3 are supported again. |