aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/lemminx/init.lua
blob: 72891a1e4ed06e2d438708eb030899c3dff82f4b (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
local server = require "nvim-lsp-installer.server"
local std = require "nvim-lsp-installer.installers.std"
local Data = require "nvim-lsp-installer.data"
local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"

local coalesce, when = Data.coalesce, Data.when

return function(name, root_dir)
    local unzipped_file = coalesce(
        when(platform.is_mac, "lemminx-osx-x86_64"),
        when(platform.is_linux, "lemminx-linux"),
        when(platform.is_win, "lemminx-win32")
    )

    return server.Server:new {
        name = name,
        root_dir = root_dir,
        languages = { "xml" },
        homepage = "https://github.com/eclipse/lemminx",
        installer = {
            function(_, callback, ctx)
                if not unzipped_file then
                    ctx.stdio_sink.stderr(
                        ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch)
                    )
                    callback(false)
                else
                    callback(true)
                end
            end,
            context.set(function(ctx)
                ctx.requested_server_version = coalesce(ctx.requested_server_version, "LATEST")
            end),
            context.capture(function(ctx)
                return std.unzip_remote(
                    ("https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/%s/%s.zip"):format(
                        ctx.requested_server_version,
                        unzipped_file
                    )
                )
            end),
            std.rename(
                platform.is_win and ("%s.exe"):format(unzipped_file) or unzipped_file,
                platform.is_win and "lemminx.exe" or "lemminx"
            ),
            context.receipt(function(receipt)
                receipt:with_primary_source(receipt.unmanaged)
            end),
        },
        default_options = {
            cmd_env = {
                PATH = process.extend_path { root_dir },
            },
        },
    }
end