forked from Davidyz/VectorCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
36 lines (35 loc) · 1.28 KB
/
Copy pathinit.lua
File metadata and controls
36 lines (35 loc) · 1.28 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
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 = {
stdout = table.concat(vim.iter(result):flatten(math.huge):totable()),
stderr = table.concat(vim.iter(error):flatten(math.huge):totable()),
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,
},
}