Merge pull request #3 from roman/381d40d7482c98b228cc3652f76036951c9ac5ac
Adding support for the latest version of vimshell
This commit is contained in:
commit
c89ef290b7
@ -14,28 +14,50 @@ function! Repl()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:CreateReplContext()
|
||||||
|
let l:context = {
|
||||||
|
\ 'fd': { 'stdin' : '', 'stdout' : '', 'stderr' : '' },
|
||||||
|
\ 'is_interactive' : 0,
|
||||||
|
\ 'is_single_command' : 1,
|
||||||
|
\ 'is_close_immediately': 1
|
||||||
|
\ }
|
||||||
|
return l:context
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:CallVimShell(args)
|
||||||
|
let l:context = s:CreateReplContext()
|
||||||
|
call vimshell#commands#iexe#init()
|
||||||
|
call vimshell#set_context(l:context)
|
||||||
|
call vimshell#execute_internal_command(
|
||||||
|
\ 'iexe', vimproc#parser#split_args(a:args),
|
||||||
|
\ l:context.fd,
|
||||||
|
\ l:context)
|
||||||
|
let b:interactive.is_close_immediately = 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! ReplRuby()
|
function! ReplRuby()
|
||||||
let l:contents = getline(0, expand('$'))
|
let l:contents = getline(0, expand('$'))
|
||||||
let l:args = 'irb --simple-prompt'
|
let l:args = 'irb --simple-prompt'
|
||||||
call vimshell#execute_internal_command(
|
|
||||||
\ 'iexe', vimproc#parser#split_args(l:args), { 'stdin' : '', 'stdout' : '', 'stderr' : '' },
|
call s:CallVimShell(l:args)
|
||||||
\ { 'is_interactive' : 0, 'is_single_command' : 1 })
|
|
||||||
let b:interactive.is_close_immediately = 1
|
" We pass the ruby program as strings to the
|
||||||
|
" REPL
|
||||||
for l:line in l:contents
|
for l:line in l:contents
|
||||||
call vimshell#interactive#send_string(l:line . "\n")
|
call vimshell#interactive#send_string(l:line . "\n", 1)
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReplHaskell()
|
function! ReplHaskell()
|
||||||
|
" Setting up the obj file for the current file
|
||||||
let l:tmpfile = tempname() . '.hs'
|
let l:tmpfile = tempname() . '.hs'
|
||||||
let l:tmpobj = tempname() . '.o'
|
let l:tmpobj = tempname() . '.o'
|
||||||
call writefile(getline(1, expand('$')), l:tmpfile, 'b')
|
call writefile(getline(1, expand('$')), l:tmpfile, 'b')
|
||||||
call vimproc#system('ghc ' . l:tmpfile . ' -o ' . l:tmpobj)
|
call vimproc#system('ghc ' . l:tmpfile . ' -o ' . l:tmpobj)
|
||||||
|
|
||||||
let l:args = 'ghci ' . l:tmpfile
|
let l:args = 'ghci ' . l:tmpfile
|
||||||
call vimshell#execute_internal_command(
|
call s:CallVimShell(l:args)
|
||||||
\ 'iexe', vimproc#parser#split_args(l:args), { 'stdin' : '', 'stdout' : '', 'stderr' : '' },
|
|
||||||
\ { 'is_interactive' : 0, 'is_single_command' : 1 })
|
|
||||||
let b:interactive.is_close_immediately = 1
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReplErlang()
|
function! ReplErlang()
|
||||||
@ -51,36 +73,29 @@ function! ReplErlang()
|
|||||||
\ 'iexe', vimproc#parser#split_args(l:args), { 'stdin' : '', 'stdout' : '', 'stderr' : '' },
|
\ 'iexe', vimproc#parser#split_args(l:args), { 'stdin' : '', 'stdout' : '', 'stderr' : '' },
|
||||||
\ { 'is_interactive' : 0, 'is_single_command' : 1 })
|
\ { 'is_interactive' : 0, 'is_single_command' : 1 })
|
||||||
let b:interactive.is_close_immediately = 1
|
let b:interactive.is_close_immediately = 1
|
||||||
call vimshell#interactive#send_string(printf("c('%s').\n", l:tmppath))
|
call vimshell#interactive#send_string(printf("c('%s').\n", l:tmppath), 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReplPython()
|
function! ReplPython()
|
||||||
let l:currentFile = expand('%:r') " current file without the extension
|
let l:currentFile = expand('%:r') " current file without the extension
|
||||||
let l:args = 'python -'
|
let l:args = 'python -'
|
||||||
call vimshell#execute_internal_command(
|
call s:CallVimShell(l:args)
|
||||||
\ 'iexe', vimproc#parser#split_args(l:args), { 'stdin': '', 'stdout': '', 'stderr': '' },
|
call vimshell#interactive#send_string(
|
||||||
\ { 'is_interactive' : 0, 'is_single_command' : 1 })
|
\ "from " . l:currentFile . " import *\n",
|
||||||
let b:interactive.is_close_immediately = 1
|
\1)
|
||||||
call vimshell#interactive#send_string("from " . l:currentFile . " import *\n")
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReplScala()
|
"function! ReplScala()
|
||||||
let l:currentFile = expand('%')
|
" let l:currentFile = expand('%')
|
||||||
let l:args = 'scala -i ' . l:currentFile
|
" let l:args = 'scala -i ' . l:currentFile
|
||||||
call vimshell#execute_internal_command(
|
" call s:CallVimShell(l:args)
|
||||||
\ 'iexe', vimproc#parser#split_args(l:args), { 'stdin' : '', 'stdout' : '', 'stderr' : '' },
|
"endfunction
|
||||||
\ { 'is_interactive' : 0, 'is_single_command' : 1 })
|
"
|
||||||
let b:interactive.is_close_immediately = 1
|
"function! ReplClojure()
|
||||||
endfunction
|
" let l:currentFile = expand('%')
|
||||||
|
" let l:args = 'clj -i ' . l:currentFile . ' -r'
|
||||||
function! ReplClojure()
|
" call s:CallVimShell(l:args)
|
||||||
let l:currentFile = expand('%')
|
"endfunction
|
||||||
let l:args = 'clj -i ' . l:currentFile . ' -r'
|
|
||||||
call vimshell#execute_internal_command(
|
|
||||||
\ 'iexe', vimproc#parser#split_args(l:args), { 'stdin' : '', 'stdout' : '', 'stderr' : '' },
|
|
||||||
\ { 'is_interactive' : 0, 'is_single_command' : 1 })
|
|
||||||
let b:interactive.is_close_immediately = 1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -nargs=0 Repl call Repl()
|
command! -nargs=0 Repl call Repl()
|
||||||
nnoremap <Space>i :<C-u>Repl<Cr>
|
nnoremap <Space>i :<C-u>Repl<Cr>
|
||||||
|
Reference in New Issue
Block a user