Open-source project
rust-lang/rust.vim avatar
rust-lang/rust.vim

rust.vim needs two lines in your vimrc, wires cargo into Syntastic, and never mentions an LSP

Vim configuration for Rust.

4,215 stars325 forksVim ScriptApache-2.0

At a glance

What is it?
rust-lang/rust.vim is the Vim plugin for Rust file detection, syntax highlighting, formatting and a few commands. This article covers the vimrc prerequisites, the six install routes, the :RustFmt, :RustPlay and :RustTest commands, and what the README leaves out.
Who is it for?
Install rust.vim if you edit Rust in Vim 8 or newer and want filetype detection, rustfmt on save and a test-under-cursor command with few moving parts. Look elsewhere if you want completion, go-to-definition or diagnostics from a language server, since the README documents none.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 27 days ago.
What is it written in?
Mainly Vim Script, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • rust-lang/rust.vim4,215 ★ · +21
Star history
Repository2026-10-092026-11-23
rust-lang/rust.vim4.2k4.2k

21 Stars in the last 45 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Most features stay off unless your vimrc contains syntax enable and filetype plugin indent on

rust.vim provides Rust file detection, syntax highlighting, formatting, Syntastic integration and more. The version floor is Vim 8, which the README says is required for full functionality. Some things may not work on earlier versions, and the README does not say which ones.

The plugin also needs two statements from you. Either the plugin manager or your `.vimrc` has to contain:

vim
syntax enable
filetype plugin indent on

The README notes that most plugin managers do not do this automatically, so users usually add the statements to their vimrc right after the plugin manager load section. Order is the detail that trips people: put them before the manager has loaded the plugin and filetype handling can miss it.

The directory layout explains why. rust.vim uses Vim's standard runtime folders: `ftdetect/` to recognise Rust files, `ftplugin/` for per-filetype settings, `indent/` for indentation and `syntax/` for highlighting. Those folders only take effect when filetype plugin and indent handling are switched on. A plugin installed without those two lines loads without error and then appears to do nothing, which is the most likely cause of a broken first install.

Six install routes exist, and only some of them update themselves

The README gives one snippet per method. With Vim 8 packages, the plugin is cloned into the start directory:

sh
git clone https://github.com/rust-lang/rust.vim ~/.vim/pack/plugins/start/rust.vim

Pathogen takes a shallow clone into the bundle folder:

sh
git clone --depth=1 https://github.com/rust-lang/rust.vim.git ~/.vim/bundle/rust.vim

The other four are one-line declarations. Vundle uses `Plugin 'rust-lang/rust.vim'`, vim-plug uses `Plug 'rust-lang/rust.vim'`, dein.vim uses `call dein#add('rust-lang/rust.vim')` and NeoBundle uses `NeoBundle 'rust-lang/rust.vim'`.

The practical difference is upkeep. The two git clone routes leave you with a directory that you must update by hand with git. The declaration routes let the manager fetch updates for you. The package route needs nothing beyond Vim 8 itself, which suits a minimal setup, while the manager routes suit people who already keep a plugin list.

No Git tags were listed when checked. Pin a Git commit for a reproducible checkout, and consult your plugin manager’s version options.

Syntastic gets cargo as a checker automatically, and there is no language server integration

Error checking goes through Syntastic. rust.vim automatically registers `cargo` as a syntax checker with Syntastic, if nothing else is specified. The repository also has a `syntax_checkers/` folder. The README points to `:help rust-syntastic` for details.

The condition matters. The phrase if nothing else is specified means a checker you configured yourself wins, and the default is only a fallback. A user who has already set a Rust checker in Syntastic will not see cargo take over.

What the README leaves out is as telling as what it includes. It names no language server, no completion engine and no go-to-definition support. The plugin's scope is the older Vim model: Syntastic for checking, Tagbar for browsing, rustfmt for formatting and a handful of commands.

If you want diagnostics or completion from rust-analyzer, you add that through another plugin or Vim's own mechanisms. This repository neither blocks nor documents that setup. Expect rust.vim to be the filetype and command layer under whatever else you install.

:RustFmt formats with rustfmt, and autosave is one variable in your vimrc

The `:RustFmt` command formats your code with rustfmt, if it is installed. The README gives the install line as `rustup component add rustfmt`. Without rustfmt present, the command has nothing to call.

Format-on-save is a separate switch. Placing `let g:rustfmt_autosave = 1` in your `~/.vimrc` makes the plugin run `:RustFmt` every time you save a buffer. It is off by default, so a fresh install formats only when you ask.

Further options live in the built-in help. The README directs you to `:help :RustFmt` for formatting help and customization options, which means the option list is in the `doc/` folder and not in the README.

One consequence of autosave is worth planning for. Every save rewrites the buffer through rustfmt, so a file that does not parse may be left untouched or may report an error, and the README does not describe how that case behaves. Teams that format in CI rather than in the editor can leave the variable unset and still use `:RustFmt` by hand.

The rustfmt link in the README points to the rust-lang-nursery organisation on GitHub, an older home for the formatter.

:RustPlay posts your selection to the playground and needs webapi-vim

The `:RustPlay` command sends the current selection to the Rust playpen, or the whole current buffer if nothing is selected. The README flags a dependency: this feature requires webapi-vim, a separate plugin by mattn, to be installed.

What you get back is a URL. If you set `g:rust_clip_command`, RustPlay copies that URL to the clipboard. The README gives two values. On a Mac the setting is `let g:rust_clip_command = 'pbcopy'`, and on Linux it is `let g:rust_clip_command = 'xclip -selection clipboard'`.

Without the variable, nothing is copied. Windows has no suggested value in the README, so a Windows user has to find a clipboard command of their own.

The feature is useful for a narrow job: sharing a snippet with someone who has no project open, or reproducing a compiler message in a minimal case. It sends code to an external web service, so a selection that contains private code or secrets leaves your machine when you run it. The README describes the destination as the Rust playpen and links to play.rust-lang.org.

:RustTest runs the test under the cursor, and Tagbar is configured only to some degree

In a Cargo project, `:RustTest` runs the test that is under the cursor. The README's reason is size: when a project is big and running all of the tests takes a long time, one test is faster. Outside a Cargo project the command is not documented to work.

Tagbar support is described more loosely. The README recommends installing Tagbar together with Universal Ctags for a good Tagbar experience. For other kinds of setups, rust.vim tries to configure Tagbar to some degree. The repository also has a `ctags/` folder.

The wording is a warning. A different tags program gives a different result, and the README does not say what to expect. If your Tagbar outline for Rust files looks thin, check that Universal Ctags is the program being used.

Both commands run through Vim and nothing else. There is no keymap listed for `:RustTest`, `:RustFmt` or `:RustPlay`, so using them often means typing the command or defining your own mapping. The README does not suggest any.

The repository carries a `compiler/` folder as well, which is part of Vim's standard layout for compiler settings. The README does not describe it.

Help tags must exist for :help rust to work, and the license is dual MIT and Apache-2.0

Detailed documentation lives in the plugin's help file. The README tells you to run `:Helptags` and then `:help rust`. Help tags, covered by `:help helptags`, need to be generated for this plugin before you can navigate the help. Most plugin managers do that automatically. When one does not, `:help rust` fails with a missing tag error until you generate them.

The repository is Vim Script, not archived, and its last push was on 2026-10-27. It has no GitHub releases. A test folder exists at the top level, and there is a `.vintrc.yml` file and a `triagebot.toml`, but the README says nothing about how tests are run.

The license needs a careful read. GitHub's metadata shows Apache-2.0. The README says that, like Rust, rust.vim is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with LICENSE-APACHE and LICENSE-MIT in the repository. You may use it under either.

The word primarily is the README's own. For a company that audits third-party code, the two license files are the authority, not the one-line GitHub field.

The plugin sits under the rust-lang organisation. The README does not make any claim about support commitments or how quickly issues are handled.

Editorial conclusion

Install rust.vim if you edit Rust in Vim 8 or newer and want filetype detection, rustfmt on save and a test-under-cursor command with few moving parts. Look elsewhere if you want completion, go-to-definition or diagnostics from a language server, since the README documents none. Before blaming the plugin for missing features, confirm that syntax enable and filetype plugin indent on are in your vimrc.

Frequently asked questions

What does rust.vim do?

rust.vim is a Vim plugin that provides Rust file detection, syntax highlighting, formatting, Syntastic integration and more. It needs Vim 8 or higher for full functionality.

How do I install rust.vim with vim-plug?

Add Plug 'rust-lang/rust.vim' to your vimrc. Your vimrc also needs syntax enable and filetype plugin indent on for the full functionality.

How do I format Rust code on save with rust.vim?

Install rustfmt with rustup component add rustfmt, then put let g:rustfmt_autosave = 1 in your vimrc. That runs :RustFmt each time you save a buffer.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. README
  4. rust-lang/rust.vim on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rust-lang-rust-vim.svg)](https://hysenlabs.com/projects/rust-lang-rust-vim)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/rust-lang-rust-vim.svg)](https://hysenlabs.com/projects/rust-lang-rust-vim)

Was this useful?