From dc7f1097467ed9b0123e21f1c81411a9ce2fad2e Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Wed, 19 Aug 2020 14:23:39 +0200 Subject: [PATCH] Add vim defer plugin --- vim/plugin/defer.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 vim/plugin/defer.vim 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 })