diff --git a/autoload/SpaceVim/layers/lang/e.vim b/autoload/SpaceVim/layers/lang/e.vim new file mode 100644 index 000000000..424f7cfd8 --- /dev/null +++ b/autoload/SpaceVim/layers/lang/e.vim @@ -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 diff --git a/autoload/SpaceVim/plugins/repl.vim b/autoload/SpaceVim/plugins/repl.vim index 0d696f34e..7c44d5325 100644 --- a/autoload/SpaceVim/plugins/repl.vim +++ b/autoload/SpaceVim/plugins/repl.vim @@ -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 diff --git a/bundle/vim-elang/ftdetect/e.vim b/bundle/vim-elang/ftdetect/e.vim new file mode 100644 index 000000000..210ca8ecd --- /dev/null +++ b/bundle/vim-elang/ftdetect/e.vim @@ -0,0 +1,2 @@ +au BufRead,BufNewFile *.e set filetype=e + diff --git a/docs/layers/lang/e.md b/docs/layers/lang/e.md new file mode 100644 index 000000000..f1594ad3e --- /dev/null +++ b/docs/layers/lang/e.md @@ -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 + + + +- [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) + + + +## 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 | + +