Add supporting clojure with leiningen
This commit is contained in:
parent
611356a709
commit
78af766e40
@ -44,6 +44,7 @@ Run `:Repl` without saving the code on a file.
|
|||||||
* Python (You can chose python2 or python3 interpreter)
|
* Python (You can chose python2 or python3 interpreter)
|
||||||
* Erlang
|
* Erlang
|
||||||
* JavaScript
|
* JavaScript
|
||||||
|
* Clojure
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ function! repl#run_repl() abort
|
|||||||
call repl#python#open_repl()
|
call repl#python#open_repl()
|
||||||
elseif &filetype ==# 'javascript'
|
elseif &filetype ==# 'javascript'
|
||||||
call repl#javascript#open_repl()
|
call repl#javascript#open_repl()
|
||||||
|
elseif &filetype ==# 'clojure'
|
||||||
|
call repl#clojure#open_repl()
|
||||||
else
|
else
|
||||||
call repl#echo_error("Sorry, repl.vim didn't support this filetype")
|
call repl#echo_error("Sorry, repl.vim didn't support this filetype")
|
||||||
endif
|
endif
|
||||||
|
23
autoload/repl/clojure.vim
Normal file
23
autoload/repl/clojure.vim
Normal 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
|
@ -28,6 +28,10 @@ let g:repl#default_filetype_repl = {
|
|||||||
\ 'javascript' : {
|
\ 'javascript' : {
|
||||||
\ 'repl' : 'node',
|
\ 'repl' : 'node',
|
||||||
\ 'opt' : '-i'
|
\ 'opt' : '-i'
|
||||||
|
\ },
|
||||||
|
\ 'clojure' : {
|
||||||
|
\ 'repl' : 'lein',
|
||||||
|
\ 'opt' : 'repl'
|
||||||
\ }
|
\ }
|
||||||
\}
|
\}
|
||||||
|
|
||||||
|
@ -8,11 +8,12 @@ endfunction
|
|||||||
|
|
||||||
function! s:suite.do_not_throw_exception_when_open_repl()
|
function! s:suite.do_not_throw_exception_when_open_repl()
|
||||||
" repl.vim can open repl
|
" repl.vim can open repl
|
||||||
setfiletype ruby | Repl | new
|
setfiletype ruby | Repl | new
|
||||||
setfiletype haskell | Repl | new
|
setfiletype haskell | Repl | new
|
||||||
setfiletype erlang | Repl | new
|
setfiletype erlang | Repl | new
|
||||||
setfiletype python | Repl | new
|
setfiletype python | Repl | new
|
||||||
setfiletype javascript | Repl | new
|
setfiletype javascript | Repl | new
|
||||||
|
setfiletype clojure | Repl | new
|
||||||
" repl.vim cannot open repl
|
" repl.vim cannot open repl
|
||||||
" but repl.vim don't throw some exception
|
" but repl.vim don't throw some exception
|
||||||
setfiletype unknown | Repl
|
setfiletype unknown | Repl
|
||||||
|
Reference in New Issue
Block a user