Add supporting clojure with leiningen

This commit is contained in:
aiya000 2016-03-03 20:43:57 +09:00
parent 611356a709
commit 78af766e40
5 changed files with 36 additions and 5 deletions

View File

@ -44,6 +44,7 @@ Run `:Repl` without saving the code on a file.
* Python (You can chose python2 or python3 interpreter)
* Erlang
* JavaScript
* Clojure
## Installation

View File

@ -20,6 +20,8 @@ function! repl#run_repl() abort
call repl#python#open_repl()
elseif &filetype ==# 'javascript'
call repl#javascript#open_repl()
elseif &filetype ==# 'clojure'
call repl#clojure#open_repl()
else
call repl#echo_error("Sorry, repl.vim didn't support this filetype")
endif

23
autoload/repl/clojure.vim Normal file
View File

@ -0,0 +1,23 @@
scriptencoding utf-8
function! repl#clojure#open_repl() abort
" Setting up the file for the current file
if &modified
" Create new file temporary
let l:module_file = tempname() . '.clj'
call writefile(getline(1, expand('$')), l:module_file)
else
let l:module_file = expand('%:p')
endif
let l:repl = repl#get_filetype_repl('clojure')
let l:exec_name = split(l:repl['repl'], ' ')[0]
if !executable(l:exec_name)
call repl#echo_error(printf("You don't have repl: '%s'", l:exec_name))
return
endif
let l:args = printf('%s %s', l:repl['repl'], l:repl['opt'])
let l:vimshell_interactive = ':VimShellInteractive' . printf("--split='%s'", g:repl_split_command)
execute l:vimshell_interactive l:args
call vimshell#interactive#send(printf('(load-file "%s")', l:module_file))
endfunction

View File

@ -28,6 +28,10 @@ let g:repl#default_filetype_repl = {
\ 'javascript' : {
\ 'repl' : 'node',
\ 'opt' : '-i'
\ },
\ 'clojure' : {
\ 'repl' : 'lein',
\ 'opt' : 'repl'
\ }
\}

View File

@ -8,11 +8,12 @@ endfunction
function! s:suite.do_not_throw_exception_when_open_repl()
" repl.vim can open repl
setfiletype ruby | Repl | new
setfiletype haskell | Repl | new
setfiletype erlang | Repl | new
setfiletype python | Repl | new
setfiletype javascript | Repl | new
setfiletype ruby | Repl | new
setfiletype haskell | Repl | new
setfiletype erlang | Repl | new
setfiletype python | Repl | new
setfiletype javascript | Repl | new
setfiletype clojure | Repl | new
" repl.vim cannot open repl
" but repl.vim don't throw some exception
setfiletype unknown | Repl