-
Notifications
You must be signed in to change notification settings - Fork 1
/
OpenREPL.vim
42 lines (33 loc) · 943 Bytes
/
OpenREPL.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
" TODO: Rename functions
" TODO: for GFM (py-gfm), ask to install if not configured
" TODO: Separate selection and core
" Use term_start()
" https://github.com/rhysd/reply.vim
" https://github.com/vlime/vlime
if exists('g:loaded_OpenREPL')
finish
endif
let g:loaded_OpenREPL = 1
" For OpenREPL
function! s:OpenREPL()
if &filetype ==? 'python'
exec 'terminal python'
elseif &filetype ==? 'ruby'
exec 'terminal irb'
elseif &filetype ==? 'scheme'
"exec 'terminal mit-scheme'
exec 'terminal chez'
elseif &filetype ==? 'haskell'
exec 'terminal ghci'
elseif &filetype ==? 'vim'
normal! gQ
endif
endfunction
command! OpenREPL call <sid>OpenREPL()
" For Visual
function! s:OpenREPLfor() range
echo 'Passed lines <'.a:firstline.','.a:lastline.'>'
let lines = getline(a:firstline,a:lastline)
let text = join(lines, '\n')
endfunction
command! -range OpenREPLfor <line1>,<line2>call <sid>OpenREPLfor()