Browser piggieback connection convenience

When you provide a port number, you are implicitly saying you're
listening for a browser connection.
This commit is contained in:
Joshua Davey 2014-05-13 17:13:13 -05:00
parent 29af4adc46
commit 99d93ceba1
2 changed files with 10 additions and 2 deletions

View File

@ -40,7 +40,10 @@ properly, and that not all operations are supported.
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.
if not invoked explicitly. If {env} is a number, the
piggieback repl-env will will use a cljs.repl.browser
(rather than a Rhino) env with the port set to the
number provided.
:Piggieback! Terminate the most recently created piggieback
session.

View File

@ -212,12 +212,17 @@ function! s:repl.piggieback(arg, ...) abort
endif
return {}
endif
let connection = s:conn_try(self.connection, 'clone')
if empty(a:arg)
let arg = ''
elseif a:arg =~# '^\d\{1,5}$'
call connection.eval("(require 'cljs.repl.browser)")
let port = matchstr(a:arg, '^\d\{1,5}$')
let arg = ' :repl-env (cljs.repl.browser/repl-env :port '.port.')'
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'))