Fix compatibility for vimshell.vim some filetypes
Fix Haskell's compatibility for vimshell.vim Fix Ruby's compatibility for vimshell.vim
This commit is contained in:
parent
d1f4473f09
commit
4536b58e5b
@ -8,56 +8,48 @@ function! Repl()
|
|||||||
elseif &filetype == 'python'
|
elseif &filetype == 'python'
|
||||||
call ReplPython()
|
call ReplPython()
|
||||||
elseif &filetype == 'scala'
|
elseif &filetype == 'scala'
|
||||||
call ReplScala()
|
echohl Error
|
||||||
|
echo 'Sorry, this filetype is not supporrted'
|
||||||
|
echohl None
|
||||||
|
"call ReplScala()
|
||||||
elseif &filetype == 'clojure'
|
elseif &filetype == 'clojure'
|
||||||
call ReplClojure()
|
echohl Error
|
||||||
|
echo 'Sorry, this filetype is not supporrted'
|
||||||
|
echohl None
|
||||||
|
"call ReplClojure()
|
||||||
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)
|
function! s:CallVimShell(args)
|
||||||
let l:context = s:CreateReplContext()
|
execute ':VimShellInteractive' a:args
|
||||||
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
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! ReplRuby()
|
function! ReplRuby()
|
||||||
let l:contents = getline(0, expand('$'))
|
" Setting up the obj file for the current file
|
||||||
let l:args = 'irb --simple-prompt'
|
if &modified
|
||||||
|
let l:module_file = tempname() . '.rb'
|
||||||
|
call writefile(getline(1, expand('$')), l:module_file)
|
||||||
|
else
|
||||||
|
let l:module_file = expand('%:p')
|
||||||
|
endif
|
||||||
|
|
||||||
call s:CallVimShell(l:args)
|
let l:args = 'irb --simple-prompt -r ' . l:module_file
|
||||||
|
execute ':VimShellInteractive' l:args
|
||||||
" We pass the ruby program as strings to the
|
|
||||||
" REPL
|
|
||||||
for l:line in l:contents
|
|
||||||
call vimshell#interactive#send_string(l:line . "\n", 1)
|
|
||||||
endfor
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReplHaskell()
|
function! ReplHaskell()
|
||||||
" Setting up the obj file for the current file
|
" Setting up the file for the current file
|
||||||
let l:tmpfile = tempname() . '.hs'
|
if &modified
|
||||||
let l:tmpobj = tempname() . '.o'
|
" Create new file temporary
|
||||||
call writefile(getline(1, expand('$')), l:tmpfile, 'b')
|
let l:module_file = tempname() . '.hs'
|
||||||
call vimproc#system('ghc ' . l:tmpfile . ' -o ' . l:tmpobj)
|
call writefile(getline(1, expand('$')), l:module_file)
|
||||||
|
else
|
||||||
|
let l:module_file = expand('%:p')
|
||||||
|
endif
|
||||||
|
|
||||||
let l:args = 'ghci ' . l:tmpfile
|
let l:args = 'ghci ' . l:module_file
|
||||||
call s:CallVimShell(l:args)
|
execute ':VimShellInteractive' l:args
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReplErlang()
|
function! ReplErlang()
|
||||||
|
Reference in New Issue
Block a user