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
|
|
|
|
|
2020-08-21 11:00:07 +00:00
|
|
|
function s:echo(message)
|
|
|
|
echom a:message
|
|
|
|
endfun
|
|
|
|
|
|
|
|
function s:notify(message)
|
|
|
|
call Defer('notify-send "Vim" "'.a:message.'"', { b -> 0 })
|
|
|
|
endfun
|
|
|
|
|
2020-08-19 12:30:17 +00:00
|
|
|
comm -complete=shellcmd -nargs=* Defer call Defer(<q-args>, { buffer -> 0 })
|
2020-08-21 11:00:07 +00:00
|
|
|
comm -complete=shellcmd -nargs=* DeferEcho call Defer(<q-args>, { buffer -> <SID>echo("Deferred job completed: ".<q-args>) })
|
|
|
|
comm -complete=shellcmd -nargs=* DeferNotify call Defer(<q-args>, { buffer -> <SID>notify("Deferred job completed:\n$ ".<q-args>) })
|