gopher.nvim/lua/gopher/_utils/runner/init.lua
Smirnov Oleksandr 6016ca57d4
refactor: use vim.system instead of pleanry (#85)
* refactor!: migrate to vim.system

* refactor(gotests): use vim.system

* refactor(iferr): use vim.system

* refactor(impl): use vim.system

* refactor(installer): use vim.system and add sync mode

* test: fix gotests' tests

* refactor(struct_tags): use vim.system

* chore(ci): install all deps explicitly

* refactor(installer)!: add sync as an option

* docs: update readme
2025-03-02 16:31:50 +02:00

39 lines
926 B
Lua

local c = require "gopher.config"
local runner = {}
---@class gopher.RunnerOpts
---@field cwd? string
---@field timeout? number
---@field stdin? boolean|string|string[]
---@field text? boolean
---@param cmd (string|number)[]
---@param on_exit fun(out:vim.SystemCompleted)
---@param opts? gopher.RunnerOpts
---@return vim.SystemObj
function runner.async(cmd, on_exit, opts)
opts = opts or {}
return vim.system(cmd, {
cwd = opts.cwd or nil,
timeout = opts.timeout or c.timeout,
stdin = opts.stdin or nil,
text = opts.text or true,
}, on_exit)
end
---@param cmd (string|number)[]
---@param opts? gopher.RunnerOpts
---@return vim.SystemCompleted
function runner.sync(cmd, opts)
opts = opts or {}
return vim
.system(cmd, {
cwd = opts.cwd or nil,
timeout = opts.timeout or c.timeout,
stdin = opts.stdin or nil,
text = opts.text or true,
})
:wait()
end
return runner