Tentatively drop support for session eval without REPL

I'm not 100% committed to this, but lets see if anyone even misses it
(including me).  My main use case for the one-off runner is jump to
source.
This commit is contained in:
Tim Pope 2014-04-03 19:36:10 -04:00
parent 095ee57d12
commit ab6d9db216
2 changed files with 13 additions and 11 deletions

View File

@ -41,10 +41,10 @@ The only external dependency is that you have either a Vim with Python support
compiled in, or `python` in your path. compiled in, or `python` in your path.
Oh, and if you don't have an nREPL connection, installing [classpath.vim][] Oh, and if you don't have an nREPL connection, installing [classpath.vim][]
lets it fall back to using `java clojure.main`, using a class path based on lets it fall back to using `java clojure.main` for some of the basics, using a
your Leiningen or Maven config. It's a bit slow, but a two-second delay is class path based on your Leiningen or Maven config. It's a bit slow, but a
vastly preferable to being forced out of my flow for a single command, in my two-second delay is vastly preferable to being forced out of my flow for a
book. single command, in my book.
[Piggieback]: https://github.com/cemerick/piggieback [Piggieback]: https://github.com/cemerick/piggieback
[classpath.vim]: https://github.com/tpope/vim-classpath [classpath.vim]: https://github.com/tpope/vim-classpath

View File

@ -388,16 +388,14 @@ function! s:oneoff.path() dict abort
endfunction endfunction
function! s:oneoff.eval(expr, options) dict abort function! s:oneoff.eval(expr, options) dict abort
if &verbose && !empty(get(a:options, 'session', 1)) if !empty(get(a:options, 'session', 1))
echohl WarningMSG throw 'Fireplace: no live REPL connection'
echomsg "No REPL found. Running java clojure.main ..."
echohl None
endif endif
return s:spawning_eval(self.classpath, a:expr, get(a:options, 'ns', self.user_ns())) return s:spawning_eval(self.classpath, a:expr, get(a:options, 'ns', self.user_ns()))
endfunction endfunction
function! s:oneoff.message(...) abort function! s:oneoff.message(...) abort
throw 'No live REPL connection' throw 'Fireplace: no live REPL connection'
endfunction endfunction
let s:oneoff.piggieback = s:oneoff.message let s:oneoff.piggieback = s:oneoff.message
@ -459,7 +457,7 @@ function! fireplace#platform(...) abort
let cp = classpath#from_vim(getbufvar(buf, '&path')) let cp = classpath#from_vim(getbufvar(buf, '&path'))
return extend({'classpath': cp, 'nr': bufnr(buf)}, s:oneoff) return extend({'classpath': cp, 'nr': bufnr(buf)}, s:oneoff)
endif endif
throw ':Connect to a REPL or install classpath.vim to evaluate code' throw 'Fireplace: :Connect to a REPL or install classpath.vim'
endfunction endfunction
function! fireplace#client(...) abort function! fireplace#client(...) abort
@ -467,7 +465,7 @@ function! fireplace#client(...) abort
let client = fireplace#platform(buf) let client = fireplace#platform(buf)
if fnamemodify(bufname(buf), ':e') ==# 'cljs' if fnamemodify(bufname(buf), ':e') ==# 'cljs'
if !has_key(client, 'connection') if !has_key(client, 'connection')
throw ':Connect to a REPL to evaluate code' throw 'Fireplace: no live REPL connection'
endif endif
if empty(client.piggiebacks) if empty(client.piggiebacks)
let result = client.piggieback('') let result = client.piggieback('')
@ -643,6 +641,10 @@ function! fireplace#echo_session_eval(expr, ...) abort
try try
echo fireplace#session_eval(a:expr, a:0 ? a:1 : {}) echo fireplace#session_eval(a:expr, a:0 ? a:1 : {})
catch /^Clojure:/ catch /^Clojure:/
catch
echohl ErrorMSG
echomsg v:exception
echohl NONE
endtry endtry
return '' return ''
endfunction endfunction