Skip to content

Instantly share code, notes, and snippets.

@vpetro
Created February 28, 2016 00:19
Show Gist options
  • Save vpetro/f757a7a6fcfbc376b616 to your computer and use it in GitHub Desktop.
Save vpetro/f757a7a6fcfbc376b616 to your computer and use it in GitHub Desktop.
Using :terminal to send code to Scala REPL
function! OpenREPL()
if !exists("g:repl_terminal_id")
botright split enew
let g:repl_terminal_id = termopen("scala")
endif
endfunction
function! PasteScala(lines)
if !exists("g:repl_terminal_id")
call OpenREPL()
endif
let toPaste = substitute(a:lines, "\n", "^M", "g")
call jobsend(g:repl_terminal_id, add([':paste', toPaste], ''))
endfunction
nmap \to :call OpenREPL()<CR>
nmap \ts :call PasteScala(@")<CR>
nmap \ta ggVGy \| :call PasteScala(@")<CR>
nmap \tl ^v$"*y \| :call PasteScala(@*)<CR>
vnoremap \tv "*y \| :call PasteScala(@*)<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment