Back to Spacevim

SpaceVim lang#rust layer

docs/layers/lang/rust.md

2.4.03.1 KB
Original Source

Available Layers >> lang#rust

<!-- vim-markdown-toc GFM --> <!-- vim-markdown-toc -->

Description

This layer is for Rust development.

Features

  • Code completion
  • Syntax checking
  • Syntax highlighting and indent
  • Documentation lookup
  • Jump to the definition.
  • Find references
  • Rename symbol
  • Cargo integration
  • Code formatting

SpaceVim also provides code runner and Language Server Protocol support for Rust. To enable LSP, you need to load the lsp layer for Rust.

Install

Layer

To use this configuration layer, update your custom configuration file with:

toml
[[layers]]
  name = "lang#rust"

language tools

  • evcxr: A REPL (Read-Eval-Print loop) for Rust.

Layer options

  • recommended_style: true/false (Enable/Disable) recommended code style for rust. This option is disabled by default.
  • format_on_save: true/false (Enable/Disable) format current buffer after save. This option is disabled by default.
  • racer_cmd: The path of racer binary. This option is racer by default.
  • rustfmt_cmd: The path of rustfmt binary. This option is rustfmt by default.

Key bindings

Key bindingsDescriptions
g dJump to definition
SPC l d / KShow doc of cursor symbol
SPC l gJump to definition
SPC l vJump to definition (vertical)
SPC l eRename symbol (needs lsp layer)
SPC l uShow references (needs lsp layer)
SPC l c bRun cargo build
SPC l c cRun cargo clean
SPC l c fRun cargo fmt
SPC l c tRun cargo test
SPC l c uRun cargo update
SPC l c BRun cargo bench
SPC l c DRun cargo doc
SPC l c rRun cargo run
SPC l c lRun cargo clippy

Note: SPC l g and SPC l v will not be available if the lsp layer is not enabled.

Inferior REPL process

Start a evcxr inferior REPL process with SPC l s i.

Send code to inferior process commands:

Key BindingsDescriptions
SPC l s bsend buffer and keep code buffer focused
SPC l s lsend line and keep code buffer focused
SPC l s ssend selection text and keep code buffer focused

Running current script

To run a rust file, you can press SPC l r to run the current file without losing focus, and the result will be shown in a runner buffer.