aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/zk/init.lua
blob: a6b3990b6275a7e6130bb3dbd49e00cb8b219975 (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
51
52
53
54
55
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local platform = require "mason-core.platform"

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

return Pkg.new {
    name = "zk",
    desc = [[A plain text note-taking assistant]],
    homepage = "https://github.com/mickael-menu/zk",
    languages = { Pkg.Lang.Markdown },
    categories = { Pkg.Cat.LSP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "mickael-menu/zk"
        platform.when {
            mac = function()
                github
                    .unzip_release_file({
                        repo = repo,
                        asset_file = coalesce(
                            when(platform.arch == "arm64", function(version)
                                return ("zk-%s-macos-arm64.zip"):format(version)
                            end),
                            when(platform.arch == "x64", function(version)
                                return ("zk-%s-macos-x86_64.zip"):format(version)
                            end)
                        ),
                    })
                    :with_receipt()
            end,
            linux = function()
                github
                    .untargz_release_file({
                        repo = repo,
                        asset_file = coalesce(
                            when(platform.arch == "arm64", function(version)
                                return ("zk-%s-linux-arm64.tar.gz"):format(version)
                            end),
                            when(platform.arch == "x64", function(version)
                                return ("zk-%s-linux-amd64.tar.gz"):format(version)
                            end),
                            when(platform.arch == "x86", function(version)
                                return ("zk-%s-linux-i386.tar.gz"):format(version)
                            end)
                        ),
                    })
                    .with_receipt()
            end,
        }
        ctx:link_bin("zk", "zk")
    end,
}