本教程配合My-Linux-config使用,基于Martins3/My-Linux-config更改,自己使用。
- 修改./plug/coc.vim文件,添加rust language sever的配置
"languageserver": {
"rust": {
"command": "rust-analyzer",
"filetypes": ["rust"],
"rootPatterns": ["Cargo.toml"]
}
}
- 安装rust-analyzer,以及build from source
- 安装rust-analyzer
rustup component add rust-src
git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyzer
# 如果你没有使用VsCode,那么仅仅只需要安装LSP server
cargo xtask install --server
注意:在执行cargo xtask install 时,如果使用了npm淘宝源,可能会报错找不到需要安装的modules,建议报错时换成npm默认源,即
npm set registry https://registry.npmjs.org/
- 使用coc-nvim配置了rust-analyzer language server, coc-rust-analyzer是coc.nvim的扩展,用于和rust-analyzer language server交互。
- gd 跳转到函数定义
- gr 跳转到函数引用
- K 查看注释