This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
repl.vim/autoload/repl.vim
2017-09-09 22:52:04 -04:00

50 lines
1.3 KiB
VimL

scriptencoding utf-8
let s:save_cpo = &cpo
set cpo&vim
"-------------------"
function! repl#echo_error(msg) abort
echohl Error
echomsg a:msg
echohl None
endfunction
function! repl#run_repl() abort
if &filetype ==# 'ruby'
call repl#ruby#open_repl()
elseif &filetype ==# 'haskell'
call repl#haskell#open_repl()
elseif &filetype ==# 'erlang'
call repl#erlang#open_repl()
elseif &filetype ==# 'python'
call repl#python#open_repl()
elseif &filetype ==# 'javascript'
call repl#javascript#open_repl()
elseif &filetype ==# 'clojure'
call repl#clojure#open_repl()
elseif &filetype ==# 'idris'
call repl#idris#open_repl()
elseif &filetype ==# 'scheme'
call repl#scheme#open_repl()
else
call repl#echo_error("Sorry, repl.vim didn't support this filetype")
endif
endfunction
" Example:
" if you didn't set g:repl_filetype_repl
" echo repl#get_filetype_repl('python')
" => {'repl': 'python', 'opt': '-i'}
function! repl#get_filetype_repl(filetype) abort
if !exists('g:repl_filetype_repl')
return g:repl#default_filetype_repl[a:filetype]
endif
let l:filetype_repl = deepcopy(g:repl#default_filetype_repl)
call extend(l:filetype_repl, g:repl_filetype_repl)
return l:filetype_repl[a:filetype]
endfunction
"-------------------"
let &cpo = s:save_cpo
unlet s:save_cpo