Add timing information to vim deferred commands
This commit is contained in:
parent
d98733c7a2
commit
0f2d8b26e1
1 changed files with 5 additions and 4 deletions
|
@ -1,9 +1,10 @@
|
|||
function Defer(command, callback)
|
||||
let l:start = strftime("%s")
|
||||
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) }
|
||||
\ "close_cb": { pipe -> a:callback({"output": l:buffer, "tstart": l:start, "tend":strftime("%s")}) }
|
||||
\ })
|
||||
endfun
|
||||
|
||||
|
@ -15,6 +16,6 @@ function s:notify(message)
|
|||
call Defer('notify-send "Vim" "'.a:message.'"', { b -> 0 })
|
||||
endfun
|
||||
|
||||
comm -complete=shellcmd -nargs=* Defer call Defer(<q-args>, { buffer -> 0 })
|
||||
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>) })
|
||||
comm -complete=shellcmd -nargs=* Defer call Defer(<q-args>, { r -> 0 })
|
||||
comm -complete=shellcmd -nargs=* DeferEcho call Defer(<q-args>, { result -> <SID>echo("Deferred job completed (".(result['tend']-result['tstart'])."s): ".<q-args>) })
|
||||
comm -complete=shellcmd -nargs=* DeferNotify call Defer(<q-args>, { result -> <SID>notify(""Deferred job completed (".(result['tend']-result['tstart'])."s):\n$ ".<q-args>) })
|
||||
|
|
Loading…
Reference in a new issue