darkrc/vim/plugin/defer.vim

11 lines
294 B
VimL
Raw Normal View History

2020-08-19 12:23:39 +00:00
function Defer(command, callback)
2020-08-19 15:32:32 +00:00
let l:buffer = []
call job_start(a:command, {
\ "out_io": "pipe",
\ "out_cb": { pipe, text -> add(l:buffer, text) },
\ "close_cb": { pipe -> a:callback(l:buffer) }
\ })
2020-08-19 12:23:39 +00:00
endfun
comm -complete=shellcmd -nargs=* Defer call Defer(<q-args>, { buffer -> 0 })