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
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
local M = {}
2
+
3
+
local logging = require("vclib.logging")
4
+
5
+
function M.run_with_timeout(cmd, opts, callback)
6
+
logging.vclib_verbose("Running command: " .. table.concat(cmd, " "))
7
+
local merged_opts = vim.tbl_deep_extend("force", { timeout = 2000 }, opts)
8
+
if callback == nil then
9
+
return vim.system(cmd, merged_opts)
10
+
end
11
+
12
+
return vim.system(cmd, merged_opts, function(out)
13
+
if out.code == 124 then
14
+
logging.vclib_verbose("Command timed out: " .. table.concat(cmd, " "))
15
+
return
16
+
end
17
+
vim.schedule(function()
18
+
callback(out)
19
+
end)
20
+
end)
21
+
end
22
+
23
+
return M