diff --git a/vim/plugin/defer.vim b/vim/plugin/defer.vim index f979db3..8f4a7ca 100644 --- a/vim/plugin/defer.vim +++ b/vim/plugin/defer.vim @@ -1,7 +1,16 @@ +function s:jobstart(command, options) + if has("nvim") + let a:options["on_exit"] = a:options["close_cb"] + return jobstart(a:command, a:options) + else + return job_start(a:command, a:options) + end +endfun + function Defer(command, callback) let l:start = strftime("%s") let l:buffer = [] - call job_start(a:command, { + call s:jobstart(a:command, { \ "out_io": "pipe", \ "out_cb": { pipe, text -> add(l:buffer, text) }, \ "close_cb": { pipe -> a:callback({"output": l:buffer, "tstart": l:start, "tend":strftime("%s")}) }