Add run-tests to cpr

Clobbering the quickfix is probably a deal breaker but hey let's try it
anyways.

References #59.
This commit is contained in:
Tim Pope 2014-04-04 00:47:46 -04:00
parent 092ab0f70e
commit 4425618825
2 changed files with 24 additions and 8 deletions

View File

@ -153,7 +153,7 @@ cp{motion} Eval/print the code indicated by {motion}.
cpp Eval/print the innermost form at the cursor. cpp Eval/print the innermost form at the cursor.
*fireplace-cpr* *fireplace-cpr*
cpr Eval a require :reload form. cpr :Require|RunTests
*fireplace-c!* *fireplace-c!*
c!{motion} Eval/replace the code indicated by {motion}. c!{motion} Eval/replace the code indicated by {motion}.

View File

@ -1045,13 +1045,15 @@ augroup END
" }}}1 " }}}1
" :Require {{{1 " :Require {{{1
function! s:Require(bang, ns) abort function! s:Require(bang, echo, ns) abort
if expand('%:e') ==# 'cljs' if expand('%:e') ==# 'cljs'
let cmd = '(load-file '.s:str(tr(a:ns ==# '' ? fireplace#ns() : a:ns, '-.', '_/').'.cljs').')' let cmd = '(load-file '.s:str(tr(a:ns ==# '' ? fireplace#ns() : a:ns, '-.', '_/').'.cljs').')'
else else
let cmd = ('(clojure.core/require '.s:qsym(a:ns ==# '' ? fireplace#ns() : a:ns).' :reload'.(a:bang ? '-all' : '').')') let cmd = ('(clojure.core/require '.s:qsym(a:ns ==# '' ? fireplace#ns() : a:ns).' :reload'.(a:bang ? '-all' : '').')')
endif endif
echo cmd if a:echo
echo cmd
endif
try try
call fireplace#session_eval(cmd) call fireplace#session_eval(cmd)
return '' return ''
@ -1060,9 +1062,19 @@ function! s:Require(bang, ns) abort
endtry endtry
endfunction endfunction
function! s:cpr() abort
let echo = "(require ".fireplace#ns().' :reload) (clojure.test/run-tests)'
try
call s:Require(0, 0, '')
catch /^Fireplace: no live REPL connection$/
endtry
call s:RunTests(0, 0)
echo echo
endfunction
function! s:setup_require() abort function! s:setup_require() abort
command! -buffer -bar -bang -complete=customlist,fireplace#ns_complete -nargs=? Require :exe s:Require(<bang>0, <q-args>) command! -buffer -bar -bang -complete=customlist,fireplace#ns_complete -nargs=? Require :exe s:Require(<bang>0, 1, <q-args>)
nnoremap <silent><buffer> cpr :Require<CR> nnoremap <silent><buffer> cpr :if expand('%:e') ==# 'cljs'<Bar>Require<Bar>else<Bar>call <SID>cpr()<Bar>endif<CR>
endfunction endfunction
augroup fireplace_require augroup fireplace_require
@ -1341,7 +1353,7 @@ function! fireplace#capture_test_run(expr) abort
cwindow cwindow
endfunction endfunction
function! s:RunTests(bang, ...) abort function! s:RunTests(bang, echo, ...) abort
if a:bang && a:0 if a:bang && a:0
let expr = '(clojure.test/run-all-tests #"'.join(a:000, '|').'")' let expr = '(clojure.test/run-all-tests #"'.join(a:000, '|').'")'
elseif a:bang elseif a:bang
@ -1351,12 +1363,16 @@ function! s:RunTests(bang, ...) abort
endif endif
call fireplace#capture_test_run(expr) call fireplace#capture_test_run(expr)
cwindow cwindow
echo expr if a:echo
echo expr
endif
endfunction endfunction
augroup fireplace_command augroup fireplace_command
autocmd! autocmd!
autocmd FileType clojure command! -buffer -bar -bang -nargs=* -complete=customlist,fireplace#ns_complete RunTests call s:RunTests(<bang>0, <f-args>) autocmd FileType clojure command! -buffer -bar -bang -nargs=*
\ -complete=customlist,fireplace#ns_complete RunTests
\ call s:RunTests(<bang>0, 1, <f-args>)
augroup END augroup END
" }}}1 " }}}1