Allow ignoring responses at transport layer

Future versions may make this async.
This commit is contained in:
Tim Pope 2014-01-16 01:02:10 -05:00
parent fef85624d3
commit e6c1f9eac1
2 changed files with 5 additions and 8 deletions

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'}, 'fireplace#nrepl#ignore') call self.message({'op': 'close'}, 'ignore')
catch catch
finally finally
unlet self.session unlet self.session
@ -136,7 +136,7 @@ function! s:nrepl_eval(expr, ...) dict abort
let response = self.process(msg) let response = self.process(msg)
catch /^Vim:Interrupt$/ catch /^Vim:Interrupt$/
if has_key(msg, 'session') if has_key(msg, 'session')
call self.message({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}, 'fireplace#nrepl#ignore') call self.message({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}, 'ignore')
endif endif
throw 'Clojure: Interrupt' throw 'Clojure: Interrupt'
endtry endtry
@ -194,9 +194,6 @@ 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 : {}

View File

@ -103,10 +103,10 @@ endfunction
function! s:nrepl_transport_call(msg, terms, sels, ...) dict abort function! s:nrepl_transport_call(msg, terms, sels, ...) dict abort
let payload = nrepl#fireplace_connection#bencode(a:msg) let payload = nrepl#fireplace_connection#bencode(a:msg)
let response = self.dispatch('call', payload, a:terms, a:sels) let response = self.dispatch('call', payload, a:terms, a:sels)
if a:0 if !a:0
return map(response, 'fireplace#nrepl#callback(v:val, "synchronous", a:1)')
else
return response return response
elseif a:1 !=# 'ignore'
return map(response, 'fireplace#nrepl#callback(v:val, "synchronous", a:1)')
endif endif
endfunction endfunction