[mirror] Make your go dev experience better
github.com/olexsmir/gopher.nvim
neovim
golang
1local c = require "gopher.config"
2local runner = {}
3
4---@class gopher.RunnerOpts
5---@field cwd? string
6---@field timeout? number
7---@field stdin? boolean|string|string[]
8---@field text? boolean
9
10---@param cmd (string|number)[]
11---@param on_exit fun(out:vim.SystemCompleted)
12---@param opts? gopher.RunnerOpts
13---@return vim.SystemObj
14function runner.async(cmd, on_exit, opts)
15 opts = opts or {}
16 return vim.system(cmd, {
17 cwd = opts.cwd or nil,
18 timeout = opts.timeout or c.timeout,
19 stdin = opts.stdin or nil,
20 text = opts.text or true,
21 }, on_exit)
22end
23
24---@param cmd (string|number)[]
25---@param opts? gopher.RunnerOpts
26---@return vim.SystemCompleted
27function runner.sync(cmd, opts)
28 opts = opts or {}
29 return vim
30 .system(cmd, {
31 cwd = opts.cwd or nil,
32 timeout = opts.timeout or c.timeout,
33 stdin = opts.stdin or nil,
34 text = opts.text or true,
35 })
36 :wait()
37end
38
39return runner