aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/lua-language-server/init.lua
blob: 1c710935c13c7e957584e2e391b67f3e9d3ce30f (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
56
57
58
59
60
61
62
63
64
local Pkg = require "mason-core.package"
local platform = require "mason-core.platform"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local path = require "mason-core.path"

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

return Pkg.new {
    name = "lua-language-server",
    desc = [[A language server that offers Lua language support - programmed in Lua.]],
    languages = { Pkg.Lang.Lua },
    categories = { Pkg.Cat.LSP },
    homepage = "https://github.com/LuaLS/lua-language-server",
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "LuaLS/lua-language-server"
        platform.when {
            unix = function()
                github
                    .untargz_release_file({
                        repo = repo,
                        asset_file = coalesce(
                            when(platform.is.mac_x64, _.format "lua-language-server-%s-darwin-x64.tar.gz"),
                            when(platform.is.mac_arm64, _.format "lua-language-server-%s-darwin-arm64.tar.gz"),
                            when(platform.is.linux_x64_gnu, _.format "lua-language-server-%s-linux-x64.tar.gz"),
                            when(platform.is.linux_arm64_gnu, _.format "lua-language-server-%s-linux-arm64.tar.gz")
                        ),
                    })
                    .with_receipt()

                ctx:link_bin(
                    "lua-language-server",
                    ctx:write_exec_wrapper(
                        "lua-language-server",
                        path.concat {
                            "bin",
                            "lua-language-server",
                        }
                    )
                )
            end,
            win = function()
                github
                    .unzip_release_file({
                        repo = repo,
                        asset_file = coalesce(
                            when(platform.is.win_x64, _.format "lua-language-server-%s-win32-x64.zip"),
                            when(platform.is.win_x86, _.format "lua-language-server-%s-win32-ia32.zip")
                        ),
                    })
                    .with_receipt()
                ctx:link_bin(
                    "lua-language-server",
                    path.concat {
                        "bin",
                        "lua-language-server.exe",
                    }
                )
            end,
        }
    end,
}