# vim-lsp + rust-analyzerを試してみた
元々rlsを使用してrustを書いていたのですが、rls-2.0としてrust-analyzerというものが
あることを知ってvimで使用できるかどうか試してみました。
環境
macOS: 10.15.4
vim: 8.2.647
vim-lsp, rust-analyzer などは2020-04-27時点での最新版を使用しています。
インストール
- 事前準備
rust-srcの追加
# rustup component add rust-src
- rust-analyzerのインストール
# git clone https://github.com/rust-analyzer/rust-analyzer # cd rust-analyzer # cargo xtask install
- vim-lspの設定
if executable('rust-analyzer') au User lsp_setup call lsp#register_server({ \ 'name': 'rust-analyzer', \ 'cmd': {server_info->['rust-analyzer']}, \ 'whitelist': ['rust'], \ }) endif
備考
rust nightly 1.47 から RUST_SRC_PATH に設定していた$(rustc --print sysroot)/lib/rustlib/src/rust/src
が
$(rustc --print sysroot)/lib/rustlib/src/rust/library
に変更しないと候補が上手くでなくなりました。