Support Erlang (erl)
This commit is contained in:
parent
960e71e83e
commit
a69d896f9b
@ -40,9 +40,6 @@ Run `:Repl` without saving the code on a file.
|
||||
* Ruby
|
||||
* Haskell
|
||||
* Python (You can chose python2 or python3 interpreter)
|
||||
|
||||
## TODO
|
||||
|
||||
* Erlang
|
||||
|
||||
## Installation
|
||||
|
@ -24,8 +24,7 @@ function! repl#run_repl()
|
||||
elseif &filetype ==# 'haskell'
|
||||
call repl#start_haskell()
|
||||
elseif &filetype ==# 'erlang'
|
||||
call s:sorry()
|
||||
"call ReplErlang()
|
||||
call repl#start_erlang()
|
||||
elseif &filetype ==# 'python'
|
||||
call repl#start_python()
|
||||
elseif &filetype ==# 'scala'
|
||||
@ -95,21 +94,30 @@ function! repl#start_python()
|
||||
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), 1)
|
||||
"endfunction
|
||||
function! repl#start_erlang()
|
||||
" FIXME: this function messes current directly with a .bean file.
|
||||
" Setting up the file for the current file
|
||||
if &modified
|
||||
" Create new file temporary
|
||||
let l:module_file = tempname() . '.erl'
|
||||
call writefile(getline(1, expand('$')), l:module_file)
|
||||
else
|
||||
let l:module_file = expand('%:p')
|
||||
endif
|
||||
|
||||
let l:repl = exists('g:repl_filetype_repl.erlang') ? g:repl_filetype_repl.erlang['repl']
|
||||
\ : g:repl#default_filetype_repl.erlang['repl']
|
||||
let l:opt = exists('g:repl_filetype_repl.erlang') ? g:repl_filetype_repl.erlang['opt']
|
||||
\ : g:repl#default_filetype_repl.erlang['opt']
|
||||
let l:args = printf('%s %s %s', l:repl, l:opt, l:module_file)
|
||||
|
||||
" Change current directory temporary
|
||||
let l:pwd = getcwd()
|
||||
cd %:p:h
|
||||
execute ':VimShellInteractive' l:args
|
||||
call vimshell#interactive#send(printf('c(%s).', fnamemodify(l:module_file, ':t:r')))
|
||||
execute 'cd' l:pwd
|
||||
endfunction
|
||||
|
||||
"function! ReplScala()
|
||||
" let l:currentFile = expand('%')
|
||||
|
@ -19,6 +19,10 @@ let g:repl#default_filetype_repl = get(g:, 'repl_filetype_repl', {
|
||||
\ 'python' : {
|
||||
\ 'repl' : 'python',
|
||||
\ 'opt' : '-i'
|
||||
\ },
|
||||
\ 'erlang' : {
|
||||
\ 'repl' : 'erl',
|
||||
\ 'opt' : ''
|
||||
\ }
|
||||
\})
|
||||
|
||||
|
Reference in New Issue
Block a user