aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/serve-d/init.lua
blob: 5509ff6e69e9d31ed8f3b4d3d263dbc95ed4b214 (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
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 = "serve-d",
    desc = [[Microsoft language server protocol implementation for D using workspace-d]],
    homepage = "https://github.com/Pure-D/serve-d",
    languages = { Pkg.Lang.D },
    categories = { Pkg.Cat.LSP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "Pure-D/serve-d"
        platform.when {
            unix = function()
                github
                    .untarxz_release_file({
                        repo = repo,
                        asset_file = function(release)
                            local target = coalesce(
                                when(platform.is.mac, "serve-d_%s-osx-x86_64.tar.xz"),
                                when(platform.is.linux_x64, "serve-d_%s-linux-x86_64.tar.xz")
                            )
                            return target and target:format(release:gsub("^v", ""))
                        end,
                    })
                    .with_receipt()
                ctx:link_bin("serve-d", "serve-d")
            end,
            win = function()
                github
                    .unzip_release_file({
                        repo = repo,
                        asset_file = function(release)
                            local target = coalesce(
                                when(platform.arch == "x64", "serve-d_%s-windows-x86_64.zip"),
                                when(platform.arch == "x86", "serve-d_%s-windows-x86.zip")
                            )
                            return target and target:format(release:gsub("^v", ""))
                        end,
                    })
                    .with_receipt()
                ctx:link_bin("serve-d", "serve-d.exe")
            end,
        }
    end,
}