【Rust】導入覚書
- 環境
- archlinux 5.0.9-arch1-1-ARCH
- rust 1.34.1
- neovim 0.3.5
rust
binary
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh echo 'source $HOME/.cargo/env' >> ~/.zshrc rustc -V rustc 1.34.1 (fc50f328b 2019-04-24) cargo -V cargo 1.34.0 (6789d8a0a 2019-04-01)
source
補完系で必要になる
rustup component add rust-src rustup update echo 'export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"' >> ~/.zshrc
component, tool, etc
formatter
https://github.com/rust-lang/rustfmt
rustup component add rustfmt
linter
https://github.com/rust-lang/rust-clippy
rustup component add clippy
watcher
https://github.com/passcod/cargo-watch
cargo install cargo-watch
Cargo.toml editor
https://github.com/killercup/cargo-edit
cargo install cargo-edit
code completion
設定面倒くなければ rls使ったほうが良いかも
https://github.com/racer-rust/racer
## From 2.1, racer needs nightly rust rustup toolchain add nightly cargo +nightly install racer
vim
dein.vimでplugin管理しているならなら以下をtomlファイルに追加し、UpdateRemotePlugins
rust.vim
detection, syntax highlighting, formatting
https://github.com/racer-rust/vim-racer
[[plugins]] repo = 'rust-lang/rust.vim' on_ft = 'rust' hook_source = ''' let g:rustfmt_autosave = 1 '''
vim-racer
vimでracerを使うplugin
https://github.com/racer-rust/vim-racer
repo = 'racer-rust/vim-racer' on_ft = 'rust' hook_source = ''' " racerバイナリ let g:racer_cmd = "~/.cargo/bin/racer" " rustソースコードパス let $RUST_SRC_PATH="~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src" 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 <leader>gd <Plug>(rust-doc) '''