Provide interface for ignoring a response

This commit is contained in:
Tim Pope 2014-01-11 18:36:13 -05:00
parent 0299eac671
commit a9c3318817

View File

@ -48,7 +48,7 @@ function! s:nrepl_close() dict abort
if has_key(self, 'session') if has_key(self, 'session')
try try
unlet! g:fireplace_nrepl_sessions[self.session] unlet! g:fireplace_nrepl_sessions[self.session]
call self.message({'op': 'close'}) call self.message({'op': 'close'}, 'fireplace#nrepl#ignore')
catch catch
finally finally
unlet self.session unlet self.session
@ -110,6 +110,7 @@ function! s:nrepl_eval(expr, ...) dict abort
if has_key(options, 'session') if has_key(options, 'session')
let msg.session = options.session let msg.session = options.session
endif endif
let msg = self.prepare(msg)
if has_key(options, 'file_path') if has_key(options, 'file_path')
let msg.op = 'load-file' let msg.op = 'load-file'
let msg['file-path'] = options.file_path let msg['file-path'] = options.file_path
@ -122,11 +123,12 @@ function! s:nrepl_eval(expr, ...) dict abort
endif endif
call remove(msg, 'code') call remove(msg, 'code')
endif endif
let msg = self.prepare(msg)
try try
let response = self.process(msg) let response = self.process(msg)
catch /^Vim:Interrupt$/ catch /^Vim:Interrupt$/
call self.call({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}) if has_key(msg, 'session')
call self.message({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}, 'fireplace#nrepl#ignore')
endif
throw 'Clojure: Interrupt' throw 'Clojure: Interrupt'
endtry endtry
if has_key(response, 'ns') && !a:0 if has_key(response, 'ns') && !a:0
@ -183,6 +185,9 @@ function! fireplace#nrepl#callback(body, type, fn)
call call(a:fn, [response]) call call(a:fn, [response])
endfunction endfunction
function! fireplace#nrepl#ignore(...) abort
endfunction
function! s:nrepl_call(msg, ...) dict abort function! s:nrepl_call(msg, ...) dict abort
let terms = a:0 ? a:1 : ['done'] let terms = a:0 ? a:1 : ['done']
let sels = a:0 > 1 ? a:2 : {} let sels = a:0 > 1 ? a:2 : {}