Make eglot not restart rust-analyzer

sometimes i end up with way too many rust-analyzer instances running, and the obvious solution is to just pkill rust-analyzer, but eglot will simply go "oh, the language server crashed, i should restart it"

is there some way to disable this behavior?

What about using M-x eglot-shutdown or M-x eglot-shutdown-all.

If Emacs is starting to many rust-analyzer's due to browsing dependencies with go to definition, then you can have eglot reuse the same rust analyzer instance.

(setq-default eglot-extend-to-xref t)

that could work if i catch the degrading performance early enough, but due to the singlethreaded nature of emacs, it has pretty poor performance on an overloaded system.

I actually tried the pkill rust-analyzer on my setup and... Eglot did not restart rust-analyzer. However, opening a new file with rust mode did trigger my (add-hook 'rust-mode #'eglot-ensure)
which started up a new rust-analyzer instance.

On my setup, I could run M-x remove-hook rust-mode-hook eglot-ensure to stop this behavior for the rest of the session.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.