Workspace setup

From Rust Community Wiki
Jump to navigation Jump to search

Installing Rust[edit | edit source]

The recommended method for installing Rust is via rustup, a command-line tool for installing the Rust toolchain and keeping it up to date. It also allows adding useful components and targets for cross-compilation.

If you use a package manager, it's likely that rustup is available as a package. For example, rustup is available as a community package in pacman and in the official NixPkgs Nix repository.

Language servers[edit | edit source]

Language servers provide code completion, detect errors prior to compilation, and do many other useful things. By using the Language Server Protocol, they are compatible with a wide range of IDEs and editors. The following popular language servers exist for Rust:

Language Server Description Installation
RLS Official language server for Rust.
It invokes rustc to get type information, which can be slow for big projects.
VS Code: Install the Rust extension
Rustup: $ rustup component add rls rust-analysis rust-src
rust-analyzer Newer language server that will eventually replace RLS.
It uses the Cargo vec.svgchalk-solve crate. It is much faster, but still contains some bugs.
VS Code: Install the rust-analyzer extension
Pacman: $ pacman -S rust-analyzer
More installation options

On the fly checking using both RLS and rust-analyzer[edit | edit source]

Currently, rust-analyzer (RA) doesn't support on the fly checking, but it's possible to install both RLS and RA, using the former for on-the-fly checking and the latter for everything else. Since both provide autocompletion, remember to disable racer for RLS in order to prevent any conflicts.

Note that this is a temporary solution and not recommended, although there is no harm in trying it if you need both RA and live diagnostics, and don't mind the increased memory usage.

IDE plugins not based on a language server[edit | edit source]

Plugin Supported IDEs Description
IntelliJ Rust JetBrains IDEs
(IntelliJ, CLion, PyCharm, ...)
It provides similar features to RLS and rust-analyzer for JetBrains IDEs.
Note that Debugging is currently only supported in CLion and IntelliJ IDEA Ultimate.

Rust Integration with IDEs[edit | edit source]

Neovim[edit | edit source]

A full article on how to setup neovim for rust can be found here: