You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
normalize async job control api for vim and neovim
sample usage
function!s:handler(job_id, data, event_type)
echoa:job_id . '' . a:event_typeechojoin(a:data, "\n")
endfunctionifhas('win32') ||has('win64')
letargv= ['cmd', '/c', 'dir c:\ /b']
elseletargv= ['bash', '-c', 'ls']
endiflet jobid =async#job#start(argv, {
\ 'on_stdout': function('s:handler'),
\ 'on_stderr': function('s:handler'),
\ 'on_exit': function('s:handler'),
\ 'normalize': 'array'\ })
if jobid > 0echom'job started'elseechom'job failed to start'endif" If you want to get the process id of the joblet pid =async#job#pid(jobid)
" If you want to wait the job:callasync#job#wait([jobid], 5000)" timeout: 5 sec" If you want to stop the job:callasync#job#stop(jobid)
By default stdout and stderr data is an array. This is a noop for neovim
but requiring using split in vim. This can tend to be costly if you are want
a string since you are joining the splited string. To avoid this unncessary
conversion you can normalize it to string so it is a noop in vim but a join
for neovim. If you prefer to disable normalization pass normalization as raw.
normalize: 'array' " Valid values are 'array', 'string' or 'raw'
Embedding
Async.vim can be either embedded with other plugins or be used as an external plugin.
If you want to embed run the following vim command.