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

Improve rust repl support (#3395)

This commit is contained in:
Wang Shidong 2020-03-04 20:13:16 +08:00 committed by GitHub
parent 43c364ee6d
commit d1a719c6ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 12 deletions

View File

@ -71,7 +71,7 @@ function! SpaceVim#layers#lang#rust#config() abort
call SpaceVim#plugins#runner#reg_runner('rust', [ call SpaceVim#plugins#runner#reg_runner('rust', [
\ 'rustc %s -o #TEMP#', \ 'rustc %s -o #TEMP#',
\ '#TEMP#']) \ '#TEMP#'])
call SpaceVim#plugins#repl#reg('rust', 'rustup run nightly-2016-08-01 ~/.cargo/bin/rusti') call SpaceVim#plugins#repl#reg('rust', 'evcxr')
let g:racer_experimental_completer = 1 let g:racer_experimental_completer = 1
let g:racer_cmd = s:racer_cmd ==# '' let g:racer_cmd = s:racer_cmd ==# ''
\ ? get(g:, 'racer_cmd', $HOME . '/.cargo/bin/racer') \ ? get(g:, 'racer_cmd', $HOME . '/.cargo/bin/racer')

View File

@ -20,8 +20,8 @@ Each of the following sections will be covered:
- [Code completion](#code-completion) - [Code completion](#code-completion)
- [Syntax linting](#syntax-linting) - [Syntax linting](#syntax-linting)
- [Jump to test file](#jump-to-test-file) - [Jump to test file](#jump-to-test-file)
- [running code](#running-code)
- [Code formatting](#code-formatting) - [Code formatting](#code-formatting)
- [running code](#running-code)
- [REPL support](#repl-support) - [REPL support](#repl-support)
<!-- vim-markdown-toc --> <!-- vim-markdown-toc -->
@ -62,14 +62,6 @@ you can add a `.project_alt.json` to the root of your project with the following
With this configuration, you can jump between the source code and test file via command `:A` With this configuration, you can jump between the source code and test file via command `:A`
### running code
To run current script, you can press `SPC l r`, and a split window
will be openen, the output of the script will be shown in this window.
It is running asynchronously, and will not block your Vim.
![rustide](https://user-images.githubusercontent.com/13142418/75607213-9afbb880-5b2f-11ea-8569-5f39142f134b.png)
### Code formatting ### Code formatting
The format layer is also enabled by default. With this layer you can use key binding `SPC b f` to format current buffer. The format layer is also enabled by default. With this layer you can use key binding `SPC b f` to format current buffer.
@ -78,10 +70,19 @@ Before using this feature, please install rustfmt:
```sh ```sh
rustup component add rustfmt rustup component add rustfmt
``` ```
### running code
To run current script, you can press `SPC l r`, and a split window
will be openen, the output of the script will be shown in this window.
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 ### REPL support
Start a `rusti` inferior REPL process with `SPC l s i`. After the REPL process being started, you can Start a `evcxr` inferior REPL process with `SPC l s i`. After the REPL process being started, you can
send code to inferior process. All key bindings prefix with `SPC l s`, including sending line, sending selection or even send code to inferior process. All key bindings prefix with `SPC l s`, including sending line, sending selection or even
send whole buffer. send whole buffer.
![rustrepl](https://user-images.githubusercontent.com/13142418/75877531-ef19dc00-5e52-11ea-87c9-bf8b103a690d.png)

View File

@ -112,5 +112,7 @@ rustup component add rustfmt
### 交互式编程 ### 交互式编程
在编辑 Rust 文件时,可通过快捷键 `SPC l s i` 启动 `rusti` 交互窗口, 在编辑 Rust 文件时,可通过快捷键 `SPC l s i` 启动 `evcxr` 交互窗口,
之后使用快捷键将代码发送至解释器。默认快捷键都以 `SPC l s` 为前缀。 之后使用快捷键将代码发送至解释器。默认快捷键都以 `SPC l s` 为前缀。
![rustrepl](https://user-images.githubusercontent.com/13142418/75877531-ef19dc00-5e52-11ea-87c9-bf8b103a690d.png)

View File

@ -11,6 +11,7 @@ lang: zh
- [模块简介](#模块简介) - [模块简介](#模块简介)
- [功能特性](#功能特性) - [功能特性](#功能特性)
- [启用模块](#启用模块) - [启用模块](#启用模块)
- [语言工具](#语言工具)
- [模块选项](#模块选项) - [模块选项](#模块选项)
- [快捷键](#快捷键) - [快捷键](#快捷键)
@ -37,6 +38,10 @@ lang: zh
name = "lang#rust" name = "lang#rust"
``` ```
### 语言工具
- [evcxr](https://github.com/google/evcxr): Rust 交互式编程命令行工具。
## 模块选项 ## 模块选项
- `recommended-style`: 1/0 (启用/禁用) rust 推荐的代码规范,该选项默认已禁用。 - `recommended-style`: 1/0 (启用/禁用) rust 推荐的代码规范,该选项默认已禁用。

View File

@ -11,6 +11,7 @@ description: "This layer is for Rust development, provide autocompletion, syntax
- [Features](#features) - [Features](#features)
- [Install](#install) - [Install](#install)
- [Layer](#layer) - [Layer](#layer)
- [language tools](#language-tools)
- [Layer options](#layer-options) - [Layer options](#layer-options)
- [Key bindings](#key-bindings) - [Key bindings](#key-bindings)
@ -46,6 +47,10 @@ To use this configuration layer, update custom configuration file with:
name = "lang#rust" name = "lang#rust"
``` ```
### language tools
- [evcxr](https://github.com/google/evcxr): A REPL (Read-Eval-Print loop) for Rust.
## Layer options ## Layer options
- `recommended-style`: 1/0 (Enable/Disable) recommended code style for rust. This option is disabled by default. - `recommended-style`: 1/0 (Enable/Disable) recommended code style for rust. This option is disabled by default.