flodiebold / lsp-rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MELPA

Rust support for lsp-mode using the Rust Language Server.

Warning: RLS is currently very unstable, which can make Emacs hang indefinitely. Using this in production isn't recommended.

Setup

First, install the RLS.

Then you should just load lsp-rust after lsp-mode by adding the following to your init file:

(with-eval-after-load 'lsp-mode
  (setq lsp-rust-rls-command '("rustup" "run" "nightly" "rls"))
  (require 'lsp-rust))

If you installed the RLS via rustup (the recommended way), then the setq line tells lsp-rust how to launch the RLS. If you would rather use the RLS_ROOT variable to locate the RLS, then set lsp-rust-rls-command to nil.

Now, you can activate lsp-mode in a Rust buffer, and you should have all the benefits of the RLS as handled by lsp-mode.

If you want on-the-fly syntax checking, first make sure that lsp-flycheck is loaded (see lsp-mode installation), then simply turn on flycheck-mode.

If you want to automatically launch lsp-mode and flycheck-mode whenever you open a rust buffer, you can add the following to your init file:

(add-hook 'rust-mode-hook #'lsp-rust-enable)
(add-hook 'rust-mode-hook #'flycheck-mode)

About

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 100.0%