feat(runner): add timeout config option
This commit is contained in:
parent
2b80f18360
commit
02cc77e81c
2 changed files with 12 additions and 5 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
|
local c = require "gopher.config"
|
||||||
local runner = {}
|
local runner = {}
|
||||||
|
|
||||||
---@class gopher.RunnerOpts
|
---@class gopher.RunnerOpts
|
||||||
---@field cwd? string
|
---@field cwd? string
|
||||||
---@field timeout? number
|
---@field timeout? number
|
||||||
---@field stdin? string|string[]
|
---@field stdin? boolean|string|string[]
|
||||||
|
---@field text? boolean
|
||||||
|
|
||||||
---@param cmd (string|number)[]
|
---@param cmd (string|number)[]
|
||||||
---@param opts? gopher.RunnerOpts
|
---@param opts? gopher.RunnerOpts
|
||||||
|
|
@ -14,9 +16,9 @@ function runner.sync(cmd, opts)
|
||||||
return vim
|
return vim
|
||||||
.system(cmd, {
|
.system(cmd, {
|
||||||
cwd = opts.cwd or nil,
|
cwd = opts.cwd or nil,
|
||||||
timeout = opts.timeout or 2000, -- TODO: move out to config
|
timeout = opts.timeout or c.timeout,
|
||||||
stdin = opts.stdin or nil,
|
stdin = opts.stdin or nil,
|
||||||
text = true,
|
text = opts.text or true,
|
||||||
})
|
})
|
||||||
:wait()
|
:wait()
|
||||||
end
|
end
|
||||||
|
|
@ -29,8 +31,9 @@ function runner.async(cmd, on_exit, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
return vim.system(cmd, {
|
return vim.system(cmd, {
|
||||||
cwd = opts.cwd or nil,
|
cwd = opts.cwd or nil,
|
||||||
timeout = opts.timeout or 2000,
|
timeout = opts.timeout or c.timeout,
|
||||||
text = true,
|
stdin = opts.stdin or nil,
|
||||||
|
text = opts.text or true,
|
||||||
}, on_exit)
|
}, on_exit)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ local default_config = {
|
||||||
---@type number
|
---@type number
|
||||||
log_level = vim.log.levels.INFO,
|
log_level = vim.log.levels.INFO,
|
||||||
|
|
||||||
|
-- timeout for running commands
|
||||||
|
---@type number
|
||||||
|
timeout = 2000,
|
||||||
|
|
||||||
-- user specified paths to binaries
|
-- user specified paths to binaries
|
||||||
---@class gopher.ConfigCommand
|
---@class gopher.ConfigCommand
|
||||||
commands = {
|
commands = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue