diff --git a/vim/plugin/defer.vim b/vim/plugin/defer.vim new file mode 100644 index 0000000..e076b86 --- /dev/null +++ b/vim/plugin/defer.vim @@ -0,0 +1,10 @@ +function Defer(command, callback) + 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) } + \ }) +endfun + +comm -nargs=* Defer call Defer(, { buffer -> 0 })