tangled
alpha
login
or
join now
algmyr.se
/
vclib.nvim
0
fork
atom
Common library code for other vc*.nvim projects.
0
fork
atom
overview
issues
pulls
pipelines
Add command running code.
algmyr.se
8 months ago
7f9f54bf
c5bdccc7
+23
1 changed file
expand all
collapse all
unified
split
lua
vclib
run.lua
+23
lua/vclib/run.lua
···
1
1
+
local M = {}
2
2
+
3
3
+
local logging = require("vclib.logging")
4
4
+
5
5
+
function M.run_with_timeout(cmd, opts, callback)
6
6
+
logging.vclib_verbose("Running command: " .. table.concat(cmd, " "))
7
7
+
local merged_opts = vim.tbl_deep_extend("force", { timeout = 2000 }, opts)
8
8
+
if callback == nil then
9
9
+
return vim.system(cmd, merged_opts)
10
10
+
end
11
11
+
12
12
+
return vim.system(cmd, merged_opts, function(out)
13
13
+
if out.code == 124 then
14
14
+
logging.vclib_verbose("Command timed out: " .. table.concat(cmd, " "))
15
15
+
return
16
16
+
end
17
17
+
vim.schedule(function()
18
18
+
callback(out)
19
19
+
end)
20
20
+
end)
21
21
+
end
22
22
+
23
23
+
return M