From 94170e4201159cd493878e5d4489417f5fbf80ee Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 31 Dec 2017 00:04:01 +0800 Subject: [PATCH] Add repl --- autoload/SpaceVim/layers/lang/dart.vim | 23 ++++++++++++++++++++++- autoload/SpaceVim/plugins/repl.vim | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/dart.vim b/autoload/SpaceVim/layers/lang/dart.vim index 2b8462d36..2ec3d8851 100644 --- a/autoload/SpaceVim/layers/lang/dart.vim +++ b/autoload/SpaceVim/layers/lang/dart.vim @@ -6,5 +6,26 @@ endfunction function! SpaceVim#layers#lang#dart#config() abort - + call SpaceVim#plugins#runner#reg_runner('dart', 'dart %s') + call SpaceVim#mapping#space#regesit_lang_mappings('dart', funcref('s:language_specified_mappings')) + call SpaceVim#plugins#repl#reg('dart', ['pub', 'global', 'run', 'dart_repl']) +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("dart")', + \ '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/autoload/SpaceVim/plugins/repl.vim b/autoload/SpaceVim/plugins/repl.vim index 807b67185..a5d3198c8 100644 --- a/autoload/SpaceVim/plugins/repl.vim +++ b/autoload/SpaceVim/plugins/repl.vim @@ -66,7 +66,7 @@ function! s:start(exe) abort \ } let s:start_time = reltime() call s:open_windows() - call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 3, 0, ['[REPL executable] ' . a:exe, '', repeat('-', 20)]) + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 3, 0, ['[REPL executable] ' . string(a:exe), '', repeat('-', 20)]) let s:lines += 3 let s:_out_data = [''] let s:_current_line = ''