From 5140b70ed0b1f9c30a40e8fceeae6491c580f4d6 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Wed, 18 Sep 2019 21:49:58 +0800 Subject: [PATCH] Update crystal layer (#3067) --- autoload/SpaceVim/layers/lang/crystal.vim | 14 ++++++ docs/cn/layers.md | 1 + docs/cn/layers/lang/crystal.md | 50 ++++++++++++++++++++ docs/layers.md | 1 + docs/layers/lang/crystal.md | 57 +++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 docs/cn/layers/lang/crystal.md create mode 100644 docs/layers/lang/crystal.md diff --git a/autoload/SpaceVim/layers/lang/crystal.vim b/autoload/SpaceVim/layers/lang/crystal.vim index 5c4692ce3..24de4b105 100644 --- a/autoload/SpaceVim/layers/lang/crystal.vim +++ b/autoload/SpaceVim/layers/lang/crystal.vim @@ -20,11 +20,25 @@ function! SpaceVim#layers#lang#crystal#plugins() abort endfunction function! SpaceVim#layers#lang#crystal#config() abort + call SpaceVim#plugins#repl#reg('crystal', 'icr') call SpaceVim#plugins#runner#reg_runner('crystal', 'crystal run --no-color %s') call SpaceVim#mapping#space#regesit_lang_mappings('crystal', function('s:language_specified_mappings')) endfunction function! s:language_specified_mappings() abort call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1) + let g:_spacevim_mappings_space.l.s = {'name' : '+Send'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'], + \ 'call SpaceVim#plugins#repl#start("crystal")', + \ 'start REPL process', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'], + \ 'call SpaceVim#plugins#repl#send("line")', + \ 'send line and keep code buffer focused', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'], + \ 'call SpaceVim#plugins#repl#send("buffer")', + \ 'send buffer and keep code buffer focused', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'], + \ 'call SpaceVim#plugins#repl#send("selection")', + \ 'send selection and keep code buffer focused', 1) endfunction diff --git a/docs/cn/layers.md b/docs/cn/layers.md index 98ae4d80b..d7e61ee21 100644 --- a/docs/cn/layers.md +++ b/docs/cn/layers.md @@ -89,6 +89,7 @@ Vim 插件以及相关配置。而 SpaceVim 是以模块的方式来组织和管 | [lang#autohotkey](lang/autohotkey/) | 这一模块为 SpaceVim 提供了 Autohotkey 的开发支持,包括语法高亮和自动补全等功能。 | | [lang#c](lang/c/) | 这一模块为 SpaceVim 提供了 C/C++/Object-C 的开发支持,包括代码补全、语法检查等特性。 | | [lang#clojure](lang/clojure/) | 这一模块为 SpaceVim 提供了 Clojure 的开发支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#crystal](lang/crystal/) | 这一模块为 crystal 开发提供支持,包括交互式编程、一键运行等特性。 | | [lang#csharp](lang/csharp/) | 这一模块为 SpaceVim 提供了 CSharp 的开发支持,包括代码高亮、对齐、补全等特性。 | | [lang#d](lang/d/) | 这一模块为 d 开发提供支持,包括语法高亮、自动补全、一键运行等特性。 | | [lang#dart](lang/dart/) | 这一模块为 SpaceVim 提供了 Dart 的开发支持,包括代码补全、语法检查、代码格式化等特性。 | diff --git a/docs/cn/layers/lang/crystal.md b/docs/cn/layers/lang/crystal.md new file mode 100644 index 000000000..901243899 --- /dev/null +++ b/docs/cn/layers/lang/crystal.md @@ -0,0 +1,50 @@ +--- +title: "SpaceVim lang#crystal 模块" +description: "这一模块为 crystal 开发提供支持,包括交互式编程、一键运行等特性。" +lang: cn +--- + +# [可用模块](../../) >> lang#crystal + + + +- [模块简介](#模块简介) +- [启用模块](#启用模块) +- [快捷键](#快捷键) + - [交互式编程](#交互式编程) + - [运行当前脚本](#运行当前脚本) + + + +## 模块简介 + +这一模块为在 SpaceVim 中进行 crystal 开发提供了支持。 + +## 启用模块 + +可通过在配置文件内加入如下配置来启用该模块: + +```toml +[[layers]] + name = "lang#crystal" +``` + +## 快捷键 + +### 交互式编程 + +启动 `icr` 交互进程,快捷键为: `SPC l s i`。 + +将代码传输给 REPL 进程执行: + +| 快捷键 | 功能描述 | +| ----------- | ----------------------- | +| `SPC l s b` | 发送整个文件内容至 REPL | +| `SPC l s l` | 发送当前行内容至 REPL | +| `SPC l s s` | 发送已选中的内容至 REPL | + +### 运行当前脚本 + +在编辑 crystal 文件时,可通过快捷键 `SPC l r` 快速异步运行当前文件,运行结果会展示在一个独立的执行窗口内。 + + diff --git a/docs/layers.md b/docs/layers.md index 68d8d10e3..4a6c93838 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -96,6 +96,7 @@ Some layers are enabled by default. The following example shows how to disable ` | [lang#c](lang/c/) | C/C++/Object-C language support for SpaceVim, include code completion, jump to definition, quick runner. | | [lang#clojure](lang/clojure/) | This layer is for Clojure development, provide autocompletion, syntax checking, code format for Clojure file. | | [lang#coffeescript](lang/coffeescript/) | This layer is for CoffeeScript development, provide autocompletion, syntax checking, code format for CoffeeScript file. | +| [lang#crystal](lang/crystal/) | This layer is for crystal development, provide syntax checking, code runner and repl support for crystal file. | | [lang#csharp](lang/csharp/) | This layer is for csharp development | | [lang#d](lang/d/) | This layer is for d development, provide syntax checking, code runner support for d file. | | [lang#dart](lang/dart/) | This layer is for Dart development, provide autocompletion, syntax checking, code format for Dart file. | diff --git a/docs/layers/lang/crystal.md b/docs/layers/lang/crystal.md new file mode 100644 index 000000000..3a38dfaf8 --- /dev/null +++ b/docs/layers/lang/crystal.md @@ -0,0 +1,57 @@ +--- +title: "SpaceVim lang#crystal layer" +description: "This layer is for crystal development, provide syntax checking, code runner and repl support for crystal file." +--- + +# [Available Layers](../../) >> lang#crystal + + + +- [Description](#description) +- [Install](#install) +- [Features](#features) +- [Key bindings](#key-bindings) + - [Running current script](#running-current-script) + - [Inferior REPL process](#inferior-repl-process) + + + +## Description + +This layer is for crystal development. + +## Install + +To use this configuration layer, update custom configuration file with: + +```toml +[[layers]] + name = "lang#crystal" +``` + +To use REPL for crystal, you need to install [icr](https://github.com/crystal-community/icr). + +## Features + +- repl support +- code runner + +## Key bindings + +### Running current script + +To running a crystal file, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer. + +### Inferior REPL process + +Start a `icr` inferior REPL process with `SPC l s i`. + +Send code to inferior process commands: + +| Key Bindings | Descriptions | +| ------------ | ------------------------------------------------ | +| `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 | + +