1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

Update rust ide post (#3537)

This commit is contained in:
Wang Shidong 2020-05-17 21:07:22 +08:00 committed by GitHub
parent d985471c82
commit 5d6df904a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,6 @@ commentsID: "Use Vim as a Rust IDE"
This is a general guide for using SpaceVim as a Rust IDE, including layer configuration and usage.
Each of the following sections will be covered:
<!-- vim-markdown-toc GFM -->
- [Enable language layer](#enable-language-layer)
@ -41,13 +40,41 @@ For more info, you can read the [lang#rust](../layers/lang/rust/) layer document
### Code completion
`lang#rust` layer will load the rust plugin automatically, unless it's overriden in your `init.toml`.
The completion menu will be opened as you type.
Code completion is provided by `autocomplete` layer, the rust language completion is provided by `lang#rust` layer.
We also recommended to use `lsp` layer for rust.
```toml
[[layers]]
name = "lsp"
```
The lsp layer uses [rls](https://github.com/rust-lang/rls) as the language server for rust, to install rls:
```sh
rustup component add rls rust-analysis rust-src
```
Add following snippet to SpaceVim config file:
```toml
[[layers]]
name = "lsp"
filetypes = [
"rust"
]
[layers.override_cmd]
rust = ["rls"]
```
### Syntax linting
The checkers layer is enabled by default. This layer provides asynchronous syntax linting via [neomake](https://github.com/neomake/neomake).
It will run rustc asynchronously.
The `checkers` layer is enabled by default. This layer provides asynchronous syntax linting via
[neomake](https://github.com/neomake/neomake). The default lint is cargo. To use rustc as default
lint, add following config to bootstrap function:
```viml
let g:neomake_rust_enabled_makers = ['rustc']
```
### Jump to test file
@ -56,8 +83,8 @@ you can add a `.project_alt.json` to the root of your project with the following
```json
{
"src/*.rs": {"alternate": "test/test_{}.rs"},
"test/test_*.rs": {"alternate": "src/{}.rs"}
"src/*.rs": { "alternate": "test/test_{}.rs" },
"test/test_*.rs": { "alternate": "src/{}.rs" }
}
```
@ -71,6 +98,7 @@ Before using this feature, please install rustfmt:
```sh
rustup component add rustfmt
```
### running code
To run current script, you can press `SPC l r`, and a split window
@ -79,7 +107,6 @@ It is running asynchronously, and will not block your Vim.
![rustide](https://user-images.githubusercontent.com/13142418/75607213-9afbb880-5b2f-11ea-8569-5f39142f134b.png)
### REPL support
Start a `evcxr` inferior REPL process with `SPC l s i`. After the REPL process being started, you can