Use Vim as a Rust development environment

Use Vim as a Rust development environment

Nov 27, 2022·

2 min read

Recently, I finished reading the grammar and entered the implementation stage. Naturally, I need to choose a suitable environment for development.

VS code I originally used has no problems in basic use, but whenever I want to install some packages, I will get an error. I believe that with a little time, these errors can be resolved, but I suddenly changed my mind, why not write in a different environment? So I turned to the built-in Vim of the system.

If the computer is not built-in, it needs to be installed separately, but I believe it will not be too difficult.

I researched the kits for building the Rust development environment on the Internet, and most of them are compatible with Vim. Usually, the color of Vim is very dull, so let’s decorate it this time. Below is my result.


autocomplete picture in down below.
I am personally satisfied with this result, after all, the original Vim is a dead color
In order to achieve the above effect, we need the following kits:

//Package Management Tool

  1. vundle
    //Rust The official Vim suite
  2. Rust.vim
    //The key to making Vim full of colors, you need to install Node.js before installing this
  3. coc.nvim
  4. coc-snippets
    //It provides features such as Rust completion and go to definition,
  5. rust-analyizer

Before this, you will need a .vimrc file for vim, which I personally built in


Here you can add the instructions suggested by Rust.vim first,

syntax enable
filetype indent on

  1. Install Vundle

git clone ~/.vim/bundle/Vundle.vim

After that you need to configure the .vimrc file according to the instructions in github.

2. Install coc.nvim

//After adding Plugin 'neoclide/coc.nvim', {'branch': 'release'} to .vimrc, enter the command
//before that, You need to install node.js

curl -sL | bash
//also yarn
// under folder of coc.nvim

npm install -g yarn
yarn install

//After installation you can do some basic vim configuration, see a basic example at

3. There are two ways to install Rust.vim here

//Install directly on vim
git clone ~/.vim/pack/plugins/start/rust.vim
//Install via Vundle
Plugin 'rust-lang/rust.vim'

4. Install coc.snippt

After opening vim, enter: CocInstall coc-snippets

5. The last step is to install rust-analyzer

:CocInstall coc-rust-analyzer

Auto-completion and function explanation

It’s basically done here, and the rest is the customization of coc.nvim, which is a very personal thing. I personally have another setting:

  1. Pmenu
  2. PmenuSel
  3. CocFloating

Nothing else has changed. If you have any practical settings, you are welcome to share them.