My attempt to make vim more rust friendly from an IDE perspective
These instructions get neovim setup for
- Autocompletion
- Live-linting
- Autoformatting
- Syntax-highlighting
- hover docs
- jump to def
Install rustup
Add ~/.cargo/bin to PATH echo "~/.cargo/bin" >> ~/.bashrc
Rust Language Server RLS
rustup toolchain install stable
rustup toolchain install nightly
rustup default stable
rustup component add rls rust-analysis rust-src
Rust Code Completion utility Racer
cargo +nightly install racer
It is recommeded to set RUST_SRC_PATH
for speed it isn't needed
echo "export RUST_SRC_PATH=\"$(rustc --print sysroot)/lib/rustlib/src/rust/src\"" >> ~/.bashrc
Format Rust code rustfmt
cargo install rustfmt-nightly
Most operating systems come with python installed Python
Need to have msgpack
>= 1.0.0
python3 -m pip install -U pynvim msgpack
coc.nvim uses nodejs. Some may not like nodejs installed. If that is the case use deoplete. There are some commits in the repo that have examples of how to use it with rust. coc.nvim
curl -sL install-node.now.sh/lts | bash
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Install neovim Neovim
Update ~/.config/nvim/init.vim
using init.vim file in source repo
cp init.vim ~/.config/nvim/
Install patched powerline font (Optional)
Start neovim
nvim
Inside neovim install plugins :PlugInstall
Inside neovim install Coc :CocInstall
Install alacritty terminal Alacritty
Copy alacritty.yml
from repo
cp alacritty.yml ~/.config/alacritty/
Install tmux Tmux
Copy tmux.conf
from repo
cp tmux.conf ~/.tmux.conf
tmux
ctrl+b I
to install plugins
ctrl+b r
to reload tmux
prettier cd ~/.config/coc/extensions
npm install coc-prettier
Open nvim
:CocConfig
Update the file
{
"coc.preferences.formatOnSaveFiletypes": ["*"]
}
- bat
- ripgrep
- fd-find
Command | Result |
---|---|
K | show doc hover |
gd | go to def |
gcc | Line comment |
F3 | Toggle NERDTree |
F2 | Toggle Tagbar |
F1 | Update tags |
SPACE = | Buffer Next |
SPACE - | Buffer Previous |