Change :Piggieback behavior for empty/port parameters

- Explicitly specify Rhino REPL when :Piggieback has no parameters

- Use Weasel REPL when port parameter is provided to :Piggieback

- Improve leading space handling for :Piggieback params

- Fall back to cljs.repl.browser if Weasel in not in classpath

- Use has_key() when checking for Weasel repl availability
This commit is contained in:
Vitaliy Vlasov 2015-09-24 20:31:42 +03:00
parent 04a7f542f5
commit 3474bd5d72

View File

@ -277,15 +277,19 @@ function! s:repl.piggieback(arg, ...) abort
let connection = s:conn_try(self.connection, 'clone') let connection = s:conn_try(self.connection, 'clone')
if empty(a:arg) if empty(a:arg)
let arg = '' let arg = '(cljs.repl.rhino/repl-env)'
elseif a:arg =~# '^\d\{1,5}$' elseif a:arg =~# '^\d\{1,5}$'
call connection.eval("(require 'cljs.repl.browser)") let replns = 'weasel.repl.websocket'
if has_key(connection.eval("(require '" . replns . ")"), 'ex')
let replns = 'cljs.repl.browser'
call connection.eval("(require '" . replns . ")")
endif
let port = matchstr(a:arg, '^\d\{1,5}$') let port = matchstr(a:arg, '^\d\{1,5}$')
let arg = ' (cljs.repl.browser/repl-env :port '.port.')' let arg = '('.replns.'/repl-env :port '.port.')'
else else
let arg = ' ' . a:arg let arg = a:arg
endif endif
let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')') let response = connection.eval('(cemerick.piggieback/cljs-repl'.' '.arg.')')
if empty(get(response, 'ex')) if empty(get(response, 'ex'))
call insert(self.piggiebacks, extend({'connection': connection}, deepcopy(s:piggieback))) call insert(self.piggiebacks, extend({'connection': connection}, deepcopy(s:piggieback)))