https://github.com/wsdjeg/job.nvim
async job control api for neovim
https://github.com/wsdjeg/job.nvim
neovim-plugin
Last synced: 24 days ago
JSON representation
async job control api for neovim
- Host: GitHub
- URL: https://github.com/wsdjeg/job.nvim
- Owner: wsdjeg
- License: gpl-3.0
- Created: 2025-04-02T08:06:39.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2025-04-22T05:48:58.000Z (26 days ago)
- Last Synced: 2025-04-22T07:04:43.115Z (26 days ago)
- Topics: neovim-plugin
- Language: Lua
- Homepage:
- Size: 20.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# job.nvim
job manager for neovim
* [Installation](#installation)
* [Usage](#usage)
* [APIs](#apis)
* [Self-Promotion](#self-promotion)## Installation
using [nvim-plug](https://github.com/wsdjeg/nvim-plug)
```lua
require("plug").add({
{
"wsdjeg/job.nvim",
},
})
```## Usage
example:
```lua
local job = require('job')
local function on_exit(id, code, single)
print('job ' .. id .. ' exit code:' .. code .. ' single:' .. single)
endlocal 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
```## APIs
| 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 |## Self-Promotion
Like this plugin? Star the repository on
GitHub.Love this plugin? Follow [me](https://wsdjeg.net/) on
[GitHub](https://github.com/wsdjeg) and
[Twitter](http://twitter.com/wsdtty).