1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-13 13:10:39 +08:00

Add lang#e layer (#4210)

This commit is contained in:
Wang Shidong 2021-04-15 23:47:29 +08:00 committed by GitHub
parent bbac004900
commit 3dadbf55df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 130 additions and 2 deletions

View File

@ -0,0 +1,53 @@
"=============================================================================
" e.vim --- E language layer
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
if exists('s:e_interpreter')
finish
endif
let s:e_interpreter = 'rune'
let s:e_jar_path = 'e.jar'
function! SpaceVim#layers#lang#e#plugins() abort
let plugins = []
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-elang', {'merged' : 0}])
return plugins
endfunction
function! SpaceVim#layers#lang#e#config() abort
call SpaceVim#plugins#repl#reg('e', shellescape(s:e_interpreter))
call SpaceVim#plugins#runner#reg_runner('e', 'java -jar ' . shellescape(s:e_jar_path) . ' --rune %s')
call SpaceVim#mapping#space#regesit_lang_mappings('e', function('s:language_specified_mappings'))
endfunction
function! s:language_specified_mappings() abort
call SpaceVim#mapping#space#langSPC('nmap', ['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("e")',
\ '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
function! SpaceVim#layers#lang#e#set_variable(var) abort
let s:e_interpreter = get(a:var, 'e_interpreter', s:e_interpreter)
let s:e_jar_path = get(a:var, 'e_jar_path', s:e_jar_path)
endfunction
function! SpaceVim#layers#lang#e#get_options() abort
return ['e_interpreter']
endfunction

View File

@ -26,6 +26,8 @@ let s:WINDOW = SpaceVim#api#import('vim#window')
let s:STRING = SpaceVim#api#import('data#string')
let s:SPI = SpaceVim#api#import('unicode#spinners')
let s:LOGGER =SpaceVim#logger#derive('repl')
augroup spacevim_repl
autocmd!
autocmd VimLeavePre * call s:close()
@ -33,9 +35,9 @@ augroup END
function! SpaceVim#plugins#repl#start(ft) abort
call s:LOGGER.info('start repl for filetype:' . a:ft)
let exe = get(s:exes, a:ft, '')
call s:LOGGER.info('get the command:' . a:ft)
if !empty(exe)
call s:start(exe)
else

View File

@ -0,0 +1,2 @@
au BufRead,BufNewFile *.e set filetype=e

71
docs/layers/lang/e.md Normal file
View File

@ -0,0 +1,71 @@
---
title: "SpaceVim lang#e layer"
description: "This layer is for e development, provide syntax checking, code runner and repl support for e file."
---
# [Available Layers](../../) >> lang#e
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Install](#install)
- [Features](#features)
- [Layer options](#layer-options)
- [Key bindings](#key-bindings)
- [Running current script](#running-current-script)
- [Inferior REPL process](#inferior-repl-process)
<!-- vim-markdown-toc -->
## Description
This layer is for [e](http://erights.org/index.html) development.
## Install
To use this configuration layer, update custom configuration file with:
```toml
[[layers]]
name = "lang#e"
```
## Features
- filetype detection
- syntax highlighting(TODO)
- repl support
- code runner
## Layer options
- `e_interpreter`: set the interpreter of e language.
- `e_jar_path`: set the jar path of `e.jar`.
for example:
```toml
[[layers]]
name = 'lang#e'
e_interpreter = 'D:\Program Files\e\rune.bat'
e_jar_path = 'D:\Program Files\e\e.jar'
```
## Key bindings
### Running current script
To running a e 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 `rune` 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 |