job manager for neovim
using nvim-plug
require("plug").add({
{
"wsdjeg/job.nvim",
},
})
example:
local job = require('job')
local function on_exit(id, code, single)
print('job ' .. id .. ' exit code:' .. code .. ' single:' .. single)
end
local cmd = { 'echo', 'hello world' }
local jobid1 = job.start(cmd, {
on_stdout = function(id, data)
vim.print(data)
end,
on_exit = on_exit,
})
vim.print(string.format('jobid is %s', jobid1))
local jobid = job.start({ 'cat' }, {
on_stdout = function(id, data)
vim.print(data)
end,
on_exit = function(id, code, single)
print('job ' .. id .. ' exit code:' .. code .. ' single:' .. single)
end,
})
job.send(jobid, { 'hello' })
job.chanclose(jobid, 'stdin')
output:
jobid is 43
{ "hello world" }
job 43 exit code:0 single:0
{ "hello" }
job 44 exit code:0 single:0
function | description |
---|---|
job.start(cmd, opt) |
start a new job |
job.stop(jobid, signal) |
stop the job with signal |
job.send(jobid, data) |
send data to specific job |
job.chanclose(jobid, std) |
close channel of a job |
Like this plugin? Star the repository on GitHub.