-
Also make sure you're running a recent nix version.
17.x
had rustup1.3
which wasn't working for me with the rust servers, but18.03
has rustup1.11.0
(currently) which works.- rustup
- binutils
- gcc
- openssl
- pkgconfig
- gnumake
-
Includes
rustc
,cargo
, and friends. Theinstall
command might fail with an obscure error if your rustup is too old. Thedefault
command activates thestable
toolchain for commands which don't specify their toolchain.$ rustup install stable $ rustup default stable
-
-
Install
rustfmt
first. The first command lists all available components. The second addsrustfmt
to your current toolchain.$ rustup component list $ rustup component add rustfmt-preview
Get the
rust.vim
plugin installed.$ cd ~/.vim/bundle $ git clone --depth=1 https://github.com/rust-lang/rust.vim.git
Configure
rust.vim
to autoformat on save and tell it how to findrustfmt
.let g:rustfmt_autosave = 1 let g:rustfmt_command = 'rustup run stable rustfmt'
-
Install
racer
. This will download and compile a lot of rust code. You'll also need to install the rust source tree.$ cargo install racer $ rustup component add rust-src
Get the
vim-racer
plugin installed.$ cd ~/.vim/bundle $ git clone https://github.com/racer-rust/vim-racer.git
Configure
vim-racer
with keyboard commands and tell it how to find the racer executable.let g:racer_cmd = '~/.cargo/bin/racer' let g:racer_experimental_completer = 1 au FileType rust nmap gd <Plug>(rust-def) au FileType rust nmap gs <Plug>(rust-def-split) au FileType rust nmap gx <Plug>(rust-def-vertical) au FileType rust nmap gr <Plug>(rust-doc)
-
Make sure you have the following nix packages installed.
- ctags
Get the
tagbar
plugin installed.$ cd ~/.vim/bundle $ git clone https://github.com/majutsushi/tagbar.git`
Configure
tagbar
to be togglable via the F8 key.nmap <F8> :TagbarToggle<CR> let g:tagbar_type_rust = { \ 'ctagstype' : 'rust', \ 'kinds' : [ \'T:types,type definitions', \'f:functions,function definitions', \'g:enum,enumeration names', \'s:structure names', \'m:modules,module names', \'c:consts,static constants', \'t:traits', \'i:impls,trait implementations', \] \}
-
-
-
Create a project directory and get into vim.
$ cargo new --bin try-rust $ cd try-rust/ $ git init . $ git add . $ vim $(git ls-files)
-
Make sure you have the following nix packages installed.
- entr
In another terminal, start a watcher to re-check your rust code every time you edit a file.
$ git ls-files | entr -c cargo check
When you change your module structure, add, or remove a file, you'll need to restart this.
-
Created
March 19, 2019 02:03
-
-
Save waynewyang/f6cb6f4c9fbb3c0f221c9f39853299a2 to your computer and use it in GitHub Desktop.
instructions for getting started with rust, vim, rustfmt, and stuff
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment