diff --git a/autoload/SpaceVim/plugins/repl.vim b/autoload/SpaceVim/plugins/repl.vim index 14f18f8ea..b211a1a6b 100644 --- a/autoload/SpaceVim/plugins/repl.vim +++ b/autoload/SpaceVim/plugins/repl.vim @@ -202,6 +202,7 @@ function! s:open_windows() abort setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber winfixheight nomodifiable set filetype=SpaceVimREPL nnoremap q :call close() + nnoremap i :call insert() augroup spacevim_repl autocmd! autocmd BufWipeout call close_repl() @@ -210,3 +211,13 @@ function! s:open_windows() abort let s:winid = win_getid(winnr()) wincmd p endfunction + +function! s:insert() abort + call inputsave() + let input = input('input >') + if !empty(input) && s:status.is_running == 1 + call s:JOB.send(s:job_id, input) + endif + normal! : + call inputrestore() +endfunction diff --git a/docs/documentation.md b/docs/documentation.md index e6f220883..c54f75a0d 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -88,7 +88,7 @@ description: "General documentation about how to use SpaceVim, including the qui - [Replace text with iedit](#replace-text-with-iedit) - [iedit states key bindings](#iedit-states-key-bindings) - [Code runner](#code-runner) - - [Read Eval Print Loop](#read-eval-print-loop) + - [REPL(read eval print loop)](#replread-eval-print-loop) - [Highlight current symbol](#highlight-current-symbol) - [Error handling](#error-handling) - [EditorConfig](#editorconfig) @@ -571,7 +571,6 @@ In font transient state: | `-` | decrease the font size | | Any other key | leave the transient state | - ### Mouse Mouse support is enabled in Normal mode and Visual mode by default. @@ -954,7 +953,6 @@ If only one file buffer is opened, a file is opened in the active window, otherw | `s g` | open file in a vertically split window | | `s v` | open file in a horizontally split window | - #### Override filetree key bindings If you want to override the default key bindings in filetree windows. You can use User autocmd in bootstrap function. for examples: @@ -2400,12 +2398,18 @@ Key bindings within code runner buffer: | `ctrl-c` | stop code runner | | `i` | open promote to insert text | -### Read Eval Print Loop +### REPL(read eval print loop) The REPL(Read Eval Print Loop) plugin provides a framework to run REPL command asynchronously. For different language, you need to checkout the doc of language layer. The repl key bindings are defined in language layer. +Key bindings within repl buffer: + +| key binding | description | +| ----------- | --------------------------- | +| `i` | open promote to insert text | + ### Highlight current symbol SpaceVim supports highlighting of the current symbol on demand and add a transient state to easily navigate and rename these symbols.