rust-analyzer / rust-analyzer.github.io

https://rust-analyzer.github.io/
87 stars 51 forks source link

Emacs instructions out of date, now setup just requires installing an lsp-client (`eglot` or `lsp-mode`) #196

Closed meliache closed 1 year ago

meliache commented 1 year ago

The emacs LSP setup documentation in manual#emacs is very of date. It's much simpler then when the instructions were written, no extra packages need to be installed other than installing an LSP client.

Emacs LSP support has grown a lot in the past years. There are two popular language servers: The first one is lsp-mode, which adds a lot of features, support LSP protocol extensions and is a bit bloated, and the lightweight which eglot, which is more minimal, extends existing emacs functionality and has been merged into the emacs29 branch (which will be the next release).

In both popular language server implementation, rust-analyzer is the default language server for rust and no extra package or customization is required other than installing eglot or lsp-mode and enabling them. I personally prefer eglot, but lsp-mode is still fine. No lsp-rust.el is needed, that has been merged into lsp-mode and is enabled by default. It seems that the linked blog post has been updated and is still valid, so this can be linked for how to setup lsp-mode, though imo it's very opinitioned.

I think it's enough to mention the two lsp client's, what their differences are and link to their respective install/quickstart documentations and maybe a one-liner how they are typically activated

Eglot

(add-hook 'rust-mode-hook #'eglot-ensure)

LSP-Mode Activate interactively via M-x lsp or load automatically via

(add-hook 'rust-mode-hook #'lsp-deferred)

Maybe I'll do a PR, but the caveat is that I'm not a rust dev, I just started doing rustlings. But I'm an experience emacs user and following emacs development and I recently switched from lsp-mode to eglot, so kind of know both.