diff --git a/autoload/SpaceVim/layers/lang/ruby.vim b/autoload/SpaceVim/layers/lang/ruby.vim index 6ba5c3509..b2d08eef0 100644 --- a/autoload/SpaceVim/layers/lang/ruby.vim +++ b/autoload/SpaceVim/layers/lang/ruby.vim @@ -33,4 +33,8 @@ function! s:language_specified_mappings() abort call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'], \ 'call SpaceVim#plugins#repl#send("selection")', \ 'send selection and keep code buffer focused', 1) + let g:_spacevim_mappings_space.l.c = {'name' : '+RuboCop'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'f'], + \ 'Noeformat rubocop', + \ 'Runs RuboCop on the currently visited file', 1) endfunction diff --git a/docs/layers/lang/ruby.md b/docs/layers/lang/ruby.md index 8993dfad3..b888a2b1f 100644 --- a/docs/layers/lang/ruby.md +++ b/docs/layers/lang/ruby.md @@ -8,8 +8,13 @@ description: "This layer is for ruby development, provide autocompletion, syntax - [Description](#description) -- [Layer Installation](#layer-installation) +- [Installation](#installation) + - [Layer](#layer) + - [Syntax checking && Code formatting](#syntax-checking--code-formatting) - [Key bindings](#key-bindings) + - [Inferior REPL process](#inferior-repl-process) + - [RuboCop](#rubocop) + - [Running current script](#running-current-script) @@ -17,8 +22,41 @@ description: "This layer is for ruby development, provide autocompletion, syntax This layer is for ruby development. -## Layer Installation +## Installation + +### Layer To use this configuration layer, add `SPLayer 'lang#ruby'` to your custom configuration file. +### Syntax checking && Code formatting + +To enable syntax checking and code formatting in spacevim, you need to install [cobocop](https://github.com/bbatsov/rubocop). + +```sh +gem install rubocop +``` + + ## Key bindings + +### Inferior REPL process + +Start a `irb` inferior REPL process with `SPC l s i`. + +Send code to inferior process commands: + +| Key Binding | Description | +| ----------- | ------------------------------------------------ | +| `SPC l s b` | send buffer and keep code buffer focused | +| `SPC l s l` | send line and keep code buffer focused | +| `SPC l s s` | send selection text and keep code buffer focused | + +### RuboCop + +| Key Binding | Description | +| ----------- | ------------------------------------------ | +| `SPC l c f` | Runs RuboCop on the currently visited file | + +### Running current script + +To running a python script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer.