:Piggieback
This commit is contained in:
parent
226c5a0fd1
commit
0095241a6f
@ -34,7 +34,8 @@ This list isn't exhaustive; see the `:help` for details.
|
|||||||
Fireplace.vim talks to nREPL. With Leiningen, it connects automatically based
|
Fireplace.vim talks to nREPL. With Leiningen, it connects automatically based
|
||||||
on `target/repl-port`, otherwise it's just a `:Connect` away. You can connect
|
on `target/repl-port`, otherwise it's just a `:Connect` away. You can connect
|
||||||
to multiple instances of nREPL for different projects, and it will use the
|
to multiple instances of nREPL for different projects, and it will use the
|
||||||
right one automatically.
|
right one automatically. ClojureScript support is just as seamless with
|
||||||
|
[Piggieback][].
|
||||||
|
|
||||||
The only external dependency is that you have either a Vim with Python support
|
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.
|
||||||
@ -45,6 +46,7 @@ your Leiningen or Maven config. It's a bit slow, but a two-second delay is
|
|||||||
vastly preferable to being forced out of my flow for a single command, in my
|
vastly preferable to being forced out of my flow for a single command, in my
|
||||||
book.
|
book.
|
||||||
|
|
||||||
|
[Piggieback]: https://github.com/cemerick/piggieback
|
||||||
[classpath.vim]: https://github.com/tpope/vim-classpath
|
[classpath.vim]: https://github.com/tpope/vim-classpath
|
||||||
|
|
||||||
### Not quite a REPL
|
### Not quite a REPL
|
||||||
|
@ -28,6 +28,20 @@ directly, which can be quite slow depending on your setup.
|
|||||||
The only adapter shipped with fireplace.vim is for nREPL. You need either
|
The only adapter shipped with fireplace.vim is for nREPL. You need either
|
||||||
|if_pyth| or the python command in your PATH.
|
|if_pyth| or the python command in your PATH.
|
||||||
|
|
||||||
|
*fireplace-piggieback* *fireplace-clojurescript*
|
||||||
|
ClojureScript is can be evaled with Piggieback if the appropriate nREPL
|
||||||
|
middleware is loaded. https://github.com/cemerick/piggieback
|
||||||
|
|
||||||
|
*fireplace-:Piggieback*
|
||||||
|
:Piggieback [{env}] Create a new nREPL session and invoke
|
||||||
|
cemerick.piggieback/cljs-repl with the given or
|
||||||
|
default (Rhino) environment. This will also happen
|
||||||
|
automatically on first eval in a ClojureScript buffer
|
||||||
|
if not invoked explicitly.
|
||||||
|
|
||||||
|
:Piggieback! Terminate the most recently created piggieback
|
||||||
|
session.
|
||||||
|
|
||||||
LEININGEN *fireplace-leiningen*
|
LEININGEN *fireplace-leiningen*
|
||||||
|
|
||||||
In addition to automatic repl connection, Clojure buffers in a Leiningen
|
In addition to automatic repl connection, Clojure buffers in a Leiningen
|
||||||
|
@ -190,6 +190,29 @@ endfunction
|
|||||||
|
|
||||||
let s:piggieback = copy(s:repl)
|
let s:piggieback = copy(s:repl)
|
||||||
|
|
||||||
|
function! s:repl.piggieback(arg, ...) abort
|
||||||
|
if a:0 && a:1
|
||||||
|
if len(self.piggiebacks)
|
||||||
|
call remove(self.piggiebacks, 0)
|
||||||
|
endif
|
||||||
|
return {}
|
||||||
|
endif
|
||||||
|
if empty(a:arg)
|
||||||
|
let arg = ''
|
||||||
|
else
|
||||||
|
let arg = ' :repl-env ' . a:arg
|
||||||
|
endif
|
||||||
|
let connection = s:conn_try(self.connection, 'clone')
|
||||||
|
let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')')
|
||||||
|
|
||||||
|
if empty(get(response, 'ex'))
|
||||||
|
call insert(self.piggiebacks, extend({'connection': connection}, deepcopy(s:piggieback)))
|
||||||
|
return {}
|
||||||
|
endif
|
||||||
|
call connection.close()
|
||||||
|
return response
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:piggieback.user_ns() abort
|
function! s:piggieback.user_ns() abort
|
||||||
return 'cljs.user'
|
return 'cljs.user'
|
||||||
endfunction
|
endfunction
|
||||||
@ -294,9 +317,15 @@ function! s:Connect(...) abort
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:piggieback(arg, remove) abort
|
||||||
|
let response = fireplace#platform().piggieback(a:arg, a:remove)
|
||||||
|
call s:output_response(response)
|
||||||
|
endfunction
|
||||||
|
|
||||||
augroup fireplace_connect
|
augroup fireplace_connect
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType clojure command! -bar -complete=customlist,s:connect_complete -nargs=* Connect :FireplaceConnect <args>
|
autocmd FileType clojure command! -bar -complete=customlist,s:connect_complete -nargs=* Connect :FireplaceConnect <args>
|
||||||
|
autocmd FileType clojure command! -bar -complete=customlist,fireplace#eval_complete -bang -nargs=* Piggieback :call s:piggieback(<q-args>, <bang>0)
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
@ -367,10 +396,12 @@ function! s:oneoff.eval(expr, options) dict abort
|
|||||||
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(symbol) abort
|
function! s:oneoff.message(...) abort
|
||||||
throw 'No live REPL connection'
|
throw 'No live REPL connection'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:oneoff.piggieback = s:oneoff.message
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
" Client {{{1
|
" Client {{{1
|
||||||
|
|
||||||
@ -439,12 +470,10 @@ function! fireplace#client(...) abort
|
|||||||
throw ':Connect to a REPL to evaluate code'
|
throw ':Connect to a REPL to evaluate code'
|
||||||
endif
|
endif
|
||||||
if empty(client.piggiebacks)
|
if empty(client.piggiebacks)
|
||||||
let connection = s:conn_try(client.connection, 'clone')
|
let result = client.piggieback('')
|
||||||
let result = connection.eval('(cemerick.piggieback/cljs-repl)')
|
|
||||||
if has_key(result, 'ex')
|
if has_key(result, 'ex')
|
||||||
return result
|
return result
|
||||||
endif
|
endif
|
||||||
call insert(client.piggiebacks, extend({'connection': connection}, deepcopy(s:piggieback)))
|
|
||||||
endif
|
endif
|
||||||
return client.piggiebacks[0]
|
return client.piggiebacks[0]
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user