supporting erlang :D

This commit is contained in:
ujihisa 2010-10-18 23:28:22 -07:00
parent af4958ad8e
commit a08763699c
2 changed files with 25 additions and 0 deletions

View File

@ -35,6 +35,12 @@ Run `:Repl` without saving the code on a file.
ghci> runTestTT tests
## Supports
* Ruby
* Haskell
* Erlang
## Installation
$ jolt install repl.vim

View File

@ -3,6 +3,8 @@ function! Repl()
call ReplRuby()
elseif &filetype == 'haskell'
call ReplHaskell()
elseif &filetype == 'erlang'
call ReplErlang()
endif
endfunction
@ -30,6 +32,23 @@ function! ReplHaskell()
let b:interactive.is_close_immediately = 1
endfunction
function! ReplErlang()
" FIXME: this function messes current directly with a .bean file.
let l:modulename = get(matchlist(join(getline(1, line('$'))), '-module(\(.\{-}\))\.'), 1, "ujihisa")
let l:tmppath = substitute(tempname(), "[^/]*$", l:modulename, '')
let l:tmpfile = l:tmppath . '.erl'
"let l:tmpobj = tempname() . '.o'
call writefile(getline(1, expand('$')), l:tmpfile, 'b')
"call vimproc#system('ghc ' . l:tmpfile . ' -o ' . l:tmpobj)
let l:args = 'erl'
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
call vimshell#interactive#send_string(printf("c('%s').\n", l:tmppath))
endfunction
command! -nargs=0 Repl call Repl()
nnoremap <Space>i :<C-u>Repl<Cr>