aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/zls/init.lua
blob: 9840964096794e0ab0d81027f911194fbdf9316e (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
local path = require "nvim-lsp-installer.path"
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local Data = require "nvim-lsp-installer.data"
local context = require "nvim-lsp-installer.installers.context"
local std = require "nvim-lsp-installer.installers.std"
local process = require "nvim-lsp-installer.process"

local coalesce, when = Data.coalesce, Data.when

return function(name, root_dir)
    local archive_name = coalesce(
        when(platform.is_mac, "x86_64-macos.tar.xz"),
        when(
            platform.is_linux,
            coalesce(
                when(platform.arch == "x64", "x86_64-linux.tar.xz"),
                when(platform.arch == "x86", "i386-linux.tar.xz")
            )
        ),
        when(platform.is_win and platform.arch == "x64", "x86_64-windows.tar.xz")
    )

    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://github.com/zigtools/zls",
        languages = { "zig" },
        installer = {
            context.use_github_release_file("zigtools/zls", archive_name),
            context.capture(function(ctx)
                return std.untarxz_remote(ctx.github_release_file)
            end),
            std.rename("bin", "package"),
            std.chmod("+x", { path.concat { "package", "zls" } }),
        },
        default_options = {
            cmd_env = {
                PATH = process.extend_path { path.concat { root_dir, "package" } },
            },
        },
    }
end