mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:00:04 +08:00
Improve scheme layer (#3299)
This commit is contained in:
parent
3ae9a01a08
commit
b7b979b878
@ -6,23 +6,48 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
if exists('s:scheme_interpreter')
|
||||
" @bug s:scheme_interpreter always return 'scheme'
|
||||
"
|
||||
" because this script will be loaded twice. This is the feature of vim,
|
||||
" when call an autoload func, vim will try to load the script again
|
||||
finish
|
||||
else
|
||||
let s:scheme_interpreter = ''
|
||||
let s:scheme_dialect = ''
|
||||
endif
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#scheme#config() abort
|
||||
if s:scheme_dialect ==# 'mit-scheme'
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', 'echo | mit-scheme --quiet --load %s && echo')
|
||||
if has('win32')
|
||||
let mit_scheme_lib = fnamemodify(s:scheme_interpreter, ':h:h') . '\lib'
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', 'echo | ' . shellescape(s:scheme_interpreter) . ' --heap 512 --library ' . shellescape(mit_scheme_lib) . ' --quiet --load %s && echo')
|
||||
call SpaceVim#plugins#repl#reg('scheme', [s:scheme_interpreter, '--heap', 512, '--library', mit_scheme_lib, '--quiet'])
|
||||
else
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', 'echo | ' . shellescape(s:scheme_interpreter) . ' --heap 512 --library "C:\Program Files (x86)\MIT-GNU Scheme\lib" --quiet --load %s && echo')
|
||||
call SpaceVim#plugins#repl#reg('scheme', [s:scheme_interpreter, '-q'])
|
||||
endif
|
||||
elseif s:scheme_dialect ==# 'guile'
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', 'echo | guile -q %s && echo')
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', 'echo | ' . shellescape(s:scheme_interpreter) . ' -q %s && echo')
|
||||
call SpaceVim#plugins#repl#reg('scheme', [s:scheme_interpreter, '-q'])
|
||||
elseif s:scheme_dialect ==# 'chez'
|
||||
" @fixme chez scheme path expr
|
||||
" in Windows it is: C:\Program Files\Chez Scheme 9.5\bin\ta6nt\scheme.exe
|
||||
" In Homebrew it is: /usr/local/bin/chez
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', shellescape(s:scheme_interpreter) . ' --script %s')
|
||||
call SpaceVim#plugins#repl#reg('scheme', [s:scheme_interpreter, '--quiet'])
|
||||
else
|
||||
try
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', 'echo | ' . s:scheme_dialect . ' %s && echo')
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
endtry
|
||||
call SpaceVim#plugins#runner#reg_runner('scheme', 'echo | ' . s:scheme_interpreter . ' %s && echo')
|
||||
call SpaceVim#plugins#repl#reg('scheme', [s:scheme_interpreter, '--silent'])
|
||||
endif
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('scheme', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#repl#reg('scheme', ['scheme', '--silent'])
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#scheme#set_variable(opt) abort
|
||||
let s:scheme_dialect = get(a:opt, 'dialect', 'mit-scheme')
|
||||
let s:scheme_interpreter = get(a:opt, 'scheme_interpreter', s:scheme_interpreter)
|
||||
let s:scheme_dialect = get(a:opt, 'scheme_dialect', s:scheme_dialect)
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
|
@ -12,12 +12,22 @@ image: https://user-images.githubusercontent.com/13142418/46590501-4e50b100-cae6
|
||||
- [模块简介](#模块简介)
|
||||
- [功能特性](#功能特性)
|
||||
- [启用模块](#启用模块)
|
||||
- [模块选项](#模块选项)
|
||||
- [快捷键](#快捷键)
|
||||
- [交互式编程](#交互式编程)
|
||||
- [运行当前脚本](#运行当前脚本)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## 模块简介
|
||||
|
||||
这一模块为 SpaceVim 提供了 Scheme 语言开发支持,包括语法高亮、语言服务器支持。
|
||||
这一模块为 SpaceVim 提供了 [Scheme](http://www.scheme-reports.org) 语言开发支持,包括语法高亮、语言服务器支持。
|
||||
目前支持的Scheme实现包括:
|
||||
|
||||
|
||||
- [MIT Scheme](http://www.gnu.org/software/mit-scheme/)
|
||||
- [Chez Scheme](https://cisco.github.io/ChezScheme/)
|
||||
- [guile](https://www.gnu.org/software/guile/)
|
||||
|
||||
## 功能特性
|
||||
|
||||
@ -33,3 +43,36 @@ image: https://user-images.githubusercontent.com/13142418/46590501-4e50b100-cae6
|
||||
[[layers]]
|
||||
name = "lang#scheme"
|
||||
```
|
||||
|
||||
## 模块选项
|
||||
|
||||
- scheme_dialect: 指定所使用的 Scheme 方言.
|
||||
- scheme_interpreter: 用于设置 Scheme 可执行文件路径.
|
||||
|
||||
例如:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = 'lang#scheme'
|
||||
scheme_dialect = 'mit-scheme'
|
||||
scheme_interpreter = 'C:\Program Files (x86)\MIT-GNU Scheme\bin\mit-scheme.exe'
|
||||
```
|
||||
|
||||
## 快捷键
|
||||
|
||||
### 交互式编程
|
||||
|
||||
启动 Scheme 交互进程,快捷键为: `SPC l s i`。
|
||||
|
||||
将代码传输给 REPL 进程执行:
|
||||
|
||||
| 快捷键 | 功能描述 |
|
||||
| ----------- | ----------------------- |
|
||||
| `SPC l s b` | 发送整个文件内容至 REPL |
|
||||
| `SPC l s l` | 发送当前行内容至 REPL |
|
||||
| `SPC l s s` | 发送已选中的内容至 REPL |
|
||||
|
||||
### 运行当前脚本
|
||||
|
||||
在编辑 Scheme 文件时,可通过快捷键 `SPC l r` 快速异步运行当前文件,
|
||||
运行结果会展示在一个独立的执行窗口内。
|
||||
|
@ -11,12 +11,21 @@ image: https://user-images.githubusercontent.com/13142418/46590501-4e50b100-cae6
|
||||
- [Description](#description)
|
||||
- [Features](#features)
|
||||
- [Install](#install)
|
||||
- [Options](#options)
|
||||
- [Key bindings](#key-bindings)
|
||||
- [Inferior REPL process](#inferior-repl-process)
|
||||
- [Running current script](#running-current-script)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## Description
|
||||
|
||||
This layer adds Scheme language support to SpaceVim. Scheme is known as mit-scheme, and the website is: <http://www.scheme-reports.org>
|
||||
This layer adds [Scheme](http://www.scheme-reports.org) support to SpaceVim.
|
||||
The following scheme dialect support has been added:
|
||||
|
||||
- [MIT Scheme](http://www.gnu.org/software/mit-scheme/)
|
||||
- [Chez Scheme](https://cisco.github.io/ChezScheme/)
|
||||
- [guile](https://www.gnu.org/software/guile/)
|
||||
|
||||
|
||||
## Features
|
||||
@ -33,3 +42,37 @@ To use this configuration layer, update custom configuration file with:
|
||||
name = "lang#scheme"
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
- scheme_dialect: specific which scheme dialect is used.
|
||||
- scheme_interpreter: option for setting scheme interperter.
|
||||
|
||||
for example:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = 'lang#scheme'
|
||||
scheme_dialect = 'mit-scheme'
|
||||
scheme_interpreter = 'C:\Program Files (x86)\MIT-GNU Scheme\bin\mit-scheme.exe'
|
||||
```
|
||||
|
||||
## Key bindings
|
||||
|
||||
### Inferior REPL process
|
||||
|
||||
Start a `scheme` 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 |
|
||||
|
||||
|
||||
### Running current script
|
||||
|
||||
To running current script, you can press `SPC l r`
|
||||
to run current file without loss focus,
|
||||
and the result will be shown in a runner buffer.
|
||||
|
Loading…
Reference in New Issue
Block a user