From 9744203353aa3924af2d4173616e6f96b2a47ede Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Wed, 23 Sep 2020 13:52:03 +0200 Subject: [PATCH] Make defer vim plugin neovim compatible --- vim/plugin/defer.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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")}) }