Enable Rust autocomplete in Neovim
Prerequisite
I use Ubuntu 20.04 and I have already install node.js.
Install neovim
apt-get install neovim
Install vimplug
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(source: https://github.com/junegunn/vim-plug)
Setup vimplug
nvim $HOME/.config/nvim/init.vim
In $HOME/.config/nvim/init.vim
call plug#begin(stdpath("data") . '/plugged')
call plug#end()
Install coc.vim
In $HOME/.config/nvim/init.vim
call plug#begin(stdpath("data") . '/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
In nvim,
:PlugInstall
Install rust-analyzer
mkdir .local/bin
curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-linux -o ~/.local/bin/rust-analyzer
chmod +x ~/.local/bin/rust-analyzer
(source: https://rust-analyzer.github.io/manual.html#rust-analyzer-language-server-binary)
Install coc-rust-analyzer
In nvim,
:CocInstall coc-rust-analyzer
Setup coc
In $HOME/.config/nvim/coc-settings.json
{"rust-analyzer.server.path": "/home/YOURNAME/.local/bin/rust-analyzer"}
Please replace YOURNAME with your name.
Open a source code in Rust
It should work.