aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/zls/init.lua
blob: 8f7f4a78e0e9dee29711972292c3f733f37c044f (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
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local path = require "mason-core.path"
local platform = require "mason-core.platform"
local std = require "mason-core.managers.std"

local coalesce, when = _.coalesce, _.when

return Pkg.new {
    name = "zls",
    desc = [[Zig LSP implementation + Zig Language Server]],
    homepage = "https://github.com/zigtools/zls",
    languages = { Pkg.Lang.Zig },
    categories = { Pkg.Cat.LSP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local asset_file = coalesce(
            when(platform.is.mac_arm64, "aarch64-macos.tar.zst"),
            when(platform.is.mac_x64, "x86_64-macos.tar.zst"),
            when(platform.is.linux_x64, "x86_64-linux.tar.zst"),
            when(platform.is.linux_x86, "i386-linux.tar.zst"),
            when(platform.is.win_x64, "x86_64-windows.tar.zst"),
            when(platform.is.win_x86, "i386-windows.tar.zst")
        )
        github
            .untarzst_release_file({
                repo = "zigtools/zls",
                asset_file = asset_file,
            })
            .with_receipt()
        std.chmod("+x", { path.concat { "bin", "zls" } })
        ctx:link_bin("zls", path.concat { "bin", platform.is.win and "zls.exe" or "zls" })
    end,
}