u/maxecharel

▲ 6 r/emacs

Eglot: ignoring server capability `:documentOnTypeFormattingProvider` can prevent stutter. Any other tips?

Just wanted to share this here. At some point, I realized that typing too fast in a buffer managed by Eglot was leading to stuttering, even small freezes when e.g. repeatedly adding new lines. The profiler led me to eglot--post-self-insert-hook and jsonrpc-request, the former referencing :documentOnTypeFormattingProvider. This 'capability', which implements automatic formatting while the user is typing (something that may not be needed for most workflows), appears to force the JSON parser to chew way too much/often JSON.

Going for


(add-to-list 'eglot-ignored-server-capabilities ':documentOnTypeFormattingProvider)

makes Eglot simply ignore this capability, and it greatly smoothed out the flow. If you experience sluggishness when you're simply typing without even calling autocompletion, this could help.

Do you have other examples of LSP server capabilities that were leading to sluggishness?

Edit: I am on Emacs 30.2 (built from source) on Linux, with Eglot 1.23

reddit.com
u/maxecharel — 1 day ago