parent
d3f7f2cf26
commit
cd3bf333bf
@ -164,6 +164,17 @@ function! s:nrepl_eval(expr, ...) dict abort
|
||||
echo "nREPL: server has bug preventing session support"
|
||||
echohl None
|
||||
endif
|
||||
elseif has_key(options, 'file_path')
|
||||
let payload.op = 'load-file'
|
||||
let payload['file-path'] = options.file_path
|
||||
let payload['file-name'] = fnamemodify(options.file_path, ':t')
|
||||
if has_key(payload, 'ns')
|
||||
let payload.file = "(in-ns '".payload.ns.") ".payload.code
|
||||
call remove(payload, 'ns')
|
||||
else
|
||||
let payload.file = payload.code
|
||||
endif
|
||||
call remove(payload, 'code')
|
||||
endif
|
||||
let response = self.process(payload)
|
||||
if has_key(response, 'ns') && !a:0
|
||||
|
@ -494,8 +494,8 @@ function! s:qfhistory() abort
|
||||
return list
|
||||
endfunction
|
||||
|
||||
function! fireplace#session_eval(expr) abort
|
||||
let response = s:eval(a:expr, {'session': 1})
|
||||
function! fireplace#eval(expr, ...) abort
|
||||
let response = s:eval(a:expr, a:0 ? a:1 : {})
|
||||
|
||||
if !empty(get(response, 'value', '')) || !empty(get(response, 'err', ''))
|
||||
call insert(s:history, {'buffer': bufnr(''), 'code': a:expr, 'ns': fireplace#ns(), 'response': response})
|
||||
@ -526,13 +526,17 @@ function! fireplace#session_eval(expr) abort
|
||||
throw err
|
||||
endfunction
|
||||
|
||||
function! fireplace#eval(expr) abort
|
||||
return fireplace#session_eval(a:expr)
|
||||
function! fireplace#session_eval(expr) abort
|
||||
return fireplace#eval(a:expr, {'session': 1})
|
||||
endfunction
|
||||
|
||||
function! fireplace#echo_session_eval(expr) abort
|
||||
return fireplace#echo_eval(a:expr, {'session': 1})
|
||||
endfunction
|
||||
|
||||
function! fireplace#echo_eval(expr, options) abort
|
||||
try
|
||||
echo fireplace#session_eval(a:expr)
|
||||
echo fireplace#eval(a:expr, a:options)
|
||||
catch /^Clojure:/
|
||||
endtry
|
||||
return ''
|
||||
@ -657,8 +661,10 @@ function! s:editop(type) abort
|
||||
endfunction
|
||||
|
||||
function! s:Eval(bang, line1, line2, count, args) abort
|
||||
let options = {}
|
||||
if a:args !=# ''
|
||||
let expr = a:args
|
||||
let options.session = 1
|
||||
else
|
||||
if a:count ==# 0
|
||||
normal! ^
|
||||
@ -671,14 +677,16 @@ function! s:Eval(bang, line1, line2, count, args) abort
|
||||
if !line1 || !line2
|
||||
return ''
|
||||
endif
|
||||
let expr = join(getline(line1, line2), "\n")
|
||||
let options.session = 0
|
||||
let options.file_path = s:buffer_path()
|
||||
let expr = repeat("\n", line1-1).join(getline(line1, line2), "\n")
|
||||
if a:bang
|
||||
exe line1.','.line2.'delete _'
|
||||
endif
|
||||
endif
|
||||
if a:bang
|
||||
try
|
||||
let result = fireplace#session_eval(expr)
|
||||
let result = fireplace#eval(expr, options)
|
||||
if a:args !=# ''
|
||||
call append(a:line1, result)
|
||||
exe a:line1
|
||||
@ -689,7 +697,7 @@ function! s:Eval(bang, line1, line2, count, args) abort
|
||||
catch /^Clojure:/
|
||||
endtry
|
||||
else
|
||||
call fireplace#echo_session_eval(expr)
|
||||
call fireplace#echo_eval(expr, options)
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user