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

return Pkg.new {
    name = "erg",
    desc = [[A statically typed language that can deeply improve the Python ecosystem.]],
    homepage = "https://github.com/erg-lang/erg",
    languages = { Pkg.Lang.Erg },
    categories = { Pkg.Cat.LSP, Pkg.Cat.Compiler },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "erg-lang/erg"
        local asset_file = _.coalesce(
            _.when(platform.is.mac_x64, "erg-x86_64-apple-darwin.tar.gz"),
            _.when(platform.is.mac_arm64, "erg-aarch64-apple-darwin.tar.gz"),
            _.when(platform.is.linux_x64_gnu, "erg-x86_64-unknown-linux-gnu.tar.gz"),
            _.when(platform.is.win_x64, "erg-x86_64-pc-windows-msvc.zip")
        )
        platform.when {
            unix = function()
                github
                    .untargz_release_file({
                        repo = repo,
                        asset_file = asset_file,
                    })
                    .with_receipt()
                ctx:link_bin("erg", "erg")
            end,
            win = function()
                github
                    .unzip_release_file({
                        repo = repo,
                        asset_file = asset_file,
                    })
                    .with_receipt()
                ctx:link_bin("erg", "erg.exe")
            end,
        }
    end,
}