blob: f394a33d329497e04756eba6d7e7197fb9986a79 (
plain) (
blame)
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
|
local platform = require "nvim-lsp-installer.platform"
local M = {}
function M.compose(installers)
if #installers == 0 then
error "No installers to compose."
end
return function(server, callback)
local function execute(idx)
installers[idx](server, function(success, result)
if not success then
-- oh no, error. exit early
callback(success, result)
elseif installers[idx - 1] then
-- iterate
execute(idx - 1)
else
-- we done
callback(success, result)
end
end)
end
execute(#installers)
end
end
function M.when(platform_table)
return function(server, callback)
if platform.is_unix() then
if platform_table.unix then
platform_table.unix(server, callback)
else
callback(false, ("Unix is not yet supported for server %q."):format(server.name))
end
elseif platform.is_win() then
if platform_table.win then
platform_table.win(server, callback)
else
callback(false, ("Windows is not yet supported for server %q."):format(server.name))
end
else
callback(false, "installers.when: Could not find installer for current platform.")
end
end
end
return M
|