-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathinit.lua
More file actions
54 lines (51 loc) · 1.74 KB
/
Copy pathinit.lua
File metadata and controls
54 lines (51 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
local vc_config = require("vectorcode.config")
local jobrunner = require("vectorcode.jobrunner.cmd")
return {
lsp = require("vectorcode.cacher.lsp"),
default = require("vectorcode.cacher.default"),
utils = {
---Checks if VectorCode has been configured properly for your project.
---See the CLI manual for details.
---@param check_item string?
---@param on_success fun(out: vim.SystemCompleted)?
---@param on_failure fun(out: vim.SystemCompleted?)?
async_check = function(check_item, on_success, on_failure)
if not vc_config.has_cli() then
if on_failure ~= nil then
on_failure()
end
return
end
check_item = check_item or "config"
jobrunner.run_async(
{ "check", check_item },
function(result, _error, code, signal)
local out_msg = nil
if type(result) == "table" and #result > 0 then
out_msg = table.concat(vim.iter(result):flatten(math.huge):totable())
elseif type(result) == "string" then
out_msg = result
end
local err_msg = nil
if type(_error) == "table" and #_error > 0 then
err_msg = table.concat(vim.iter(_error):flatten(math.huge):totable())
elseif type(_error) == "string" then
out_msg = _error
end
local out = {
stdout = out_msg,
stderr = err_msg,
code = code,
signal = signal,
}
if out.code == 0 and type(on_success) == "function" then
vim.schedule_wrap(on_success)(out)
elseif out.code ~= 0 and type(on_failure) == "function" then
vim.schedule_wrap(on_failure)(out)
end
end,
0
)
end,
},
}