Are you looking for a more comfortable editing experience you only know from Java IDEs or Visual Studio? Then this post is for you!
Java IDEs and Visual Studio are known for a rich editing experience, providing a long list of features helping developers to get done more in less time. Now you can get the same set of features when editing Rust code.
Table of contents
1. rust-analyzer
/ The All-In-One Toolbox
If you only install one extension from this list: choose rust-analyzer.
At its core, rust-analyzer is a library for semantic analysis of Rust code as it changes over time.
From the User Manual
rust-analyzer
provides many features you might know from Visual Studio or Java IDEs. To name a few:
By default, rust-analyzer
is editor-agnostic and runs in the background. Within VSCode, it runs as a Language Server. Because it’s IDE-agnostic, there are also packages available for [other editors] (https://rust-analyzer.github.io/manual.html#installation).
This plugin is a huge productivity booster because it minimizes the number of times you need to switch between the editor and the command line to compile your code. Instead, you receive feedback in place while editing.
2. Visual Aids with Error-Lens
Error Lens provides visual aids in your editor by making errors stand out more prominently. It highlights the entire line wherever diagnostics are created. Whenever there’s an issue with a line of code, the problem gets highlighted prominently, so it catches your eye right away.
3. Adding crates without context-switching: “Search crates.io”
Whenever your need to add a new crate, do you know all versions off the top of your head? I certainly don’t and therefore have to default back to crates.io. It’s a minor inconvenience, but it costs time. The extension Search crates.io
helps with this. Once you start adding a new crate to your Cargo.toml
, it automatically finds the latest version for you, so you only need to accept the auto-complete. It’s an excellent time-saver and allows you to stay in the zone.
4. TOML Language Support
What happens when you open a Cargo.toml
file in VSCode? You look at a file without any syntax highlighting. There’s no out-of-the-box support for .toml
files. Therefore adding TOML Language
will help make Cargo.toml
files more readable.
Final Thoughts
Of course, there are many more Rust extensions out there. If you’re looking to get started quickly without too much upfront configuration, I recommend going with these four recommendations.
What other extensions are you using? Share them with me on Twitter!
Please take a look at my extension, https://marketplace.visualstudio.com/items?itemName=serayuzgur.crates