]> git.eshelyaron.com Git - emacs.git/commit
Eglot: simplify inlay hints implementation with jit-lock
authorJoão Távora <joaotavora@gmail.com>
Thu, 23 Feb 2023 23:51:09 +0000 (23:51 +0000)
committerJoão Távora <joaotavora@gmail.com>
Fri, 24 Feb 2023 02:14:44 +0000 (02:14 +0000)
commitb0cbd5590b238fa9001e3f07b7035704ef976722
tree6ca0f6a45022893ccfdb0568dab4e496eeadbad1
parent91e24c5b5a69495bcd706a5287c05bb5fd282700
Eglot: simplify inlay hints implementation with jit-lock

This implementation is much simpler than the one based on
windows-scroll-functions.  It's also supposedly safer, as long as
jit-lock guarantees refontification of affected regions.

It's not _trivially_ simple though, as simply adding
'eglot--update-hints-1' to jit-lock-functions, while possible, is
going to request inlay hints from the LSP server for many small
regions of the buffer, depending on what jit-lock thinks is best.  So
we keep coalescing these into a larger region until the time is
suitable for a more bandwidth-efficient request.

To do this, we use a jit-lock implementation detail,
jit-lock-context-unfontify-pos, which is a proxy for knowing that the
jit-lock-context-timer has run.  Not sure how brittle it is, but it
seems to work reasonably.

We also get rid of the previous "get hints for entire buffer"
implementation.

* doc/misc/eglot.texi (Eglot Variables): Remove mention
to deleted eglot-lazy-inlay-hints.

* lisp/progmodes/eglot.el (eglot-lazy-inlay-hints)
(eglot--inlay-hints-after-scroll)
(eglot--inlay-hints-fully)
(eglot--inlay-hints-lazily): Remove.
(eglot--update-hints): Add function.
(eglot-inlay-hints-mode): Simplify.
doc/misc/eglot.texi
lisp/progmodes/eglot.el