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.
Colorful!
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
//github.com/VundleVim/Vundle.vim
- vundle
//Rust The official Vim suite
//github.com/rust-lang/rust.vim - Rust.vim
//The key to making Vim full of colors, you need to install Node.js before installing this
//github.com/neoclide/coc.nvim
//github.com/neoclide/coc-snippets - coc.nvim
- coc-snippets
//It provides features such as Rust completion and go to definition,
//github.com/rust-lang/rust-analyzer - rust-analyizer
Before this, you will need a .vimrc file for vim, which I personally built in
$HOME/.vim/.vimrc
Here you can add the instructions suggested by Rust.vim first,
syntax enable
filetype indent on
- Install Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.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
//:PluginInstall
//before that, You need to install node.js
curl -sL install-node.vercel.app/lts | bash
//also yarn
// under folder of coc.nvim
//~/.vim/plugged/coc.nvim/
npm install -g yarn
yarn install
//After installation you can do some basic vim configuration, see a basic example at https://github.com/neoclide/coc.nvim
3. There are two ways to install Rust.vim here
//Install directly on vim
git clone github.com/rust-lang/rust.vim ~/.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:
- Pmenu
- PmenuSel
- CocFloating
Nothing else has changed. If you have any practical settings, you are welcome to share them.