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 = {}
|
||||
|
||||
---@class gopher.RunnerOpts
|
||||
---@field cwd? string
|
||||
---@field timeout? number
|
||||
---@field stdin? string|string[]
|
||||
---@field stdin? boolean|string|string[]
|
||||
---@field text? boolean
|
||||
|
||||
---@param cmd (string|number)[]
|
||||
---@param opts? gopher.RunnerOpts
|
||||
|
|
@ -14,9 +16,9 @@ function runner.sync(cmd, opts)
|
|||
return vim
|
||||
.system(cmd, {
|
||||
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,
|
||||
text = true,
|
||||
text = opts.text or true,
|
||||
})
|
||||
:wait()
|
||||
end
|
||||
|
|
@ -29,8 +31,9 @@ function runner.async(cmd, on_exit, opts)
|
|||
opts = opts or {}
|
||||
return vim.system(cmd, {
|
||||
cwd = opts.cwd or nil,
|
||||
timeout = opts.timeout or 2000,
|
||||
text = true,
|
||||
timeout = opts.timeout or c.timeout,
|
||||
stdin = opts.stdin or nil,
|
||||
text = opts.text or true,
|
||||
}, on_exit)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ local default_config = {
|
|||
---@type number
|
||||
log_level = vim.log.levels.INFO,
|
||||
|
||||
-- timeout for running commands
|
||||
---@type number
|
||||
timeout = 2000,
|
||||
|
||||
-- user specified paths to binaries
|
||||
---@class gopher.ConfigCommand
|
||||
commands = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue