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

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

return Pkg.new {
    name = "lemminx",
    desc = [[XML Language Server]],
    homepage = "https://github.com/eclipse/lemminx",
    languages = { Pkg.Lang.XML },
    categories = { Pkg.Cat.LSP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local unzipped_file = assert(
            coalesce(
                when(platform.is.mac, "lemminx-osx-x86_64"),
                when(platform.is.linux_x64, "lemminx-linux"),
                when(platform.is.win, "lemminx-win32")
            ),
            ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch)
        )

        std.download_file(
            ("https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/%s/%s.zip"):format(
                ctx.requested_version:or_else "0.19.2-655", -- TODO: resolve latest version dynamically
                unzipped_file
            ),
            "lemminx.zip"
        )
        std.unzip("lemminx.zip", ".")
        ctx.fs:rename(
            platform.is.win and ("%s.exe"):format(unzipped_file) or unzipped_file,
            platform.is.win and "lemminx.exe" or "lemminx"
        )
        ctx.receipt:with_primary_source(ctx.receipt.unmanaged)
        ctx:link_bin("lemminx", platform.is.win and "lemminx.exe" or "lemminx")
    end,
}