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

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

return function(name, root_dir)
    local release_file = coalesce(
        when(
            platform.is_mac,
            coalesce(
                when(platform.arch == "x64", "macos.tar.gz"),
                when(platform.arch == "arm64", "macos-aarch64.tar.gz")
            )
        ),
        when(
            platform.is_linux,
            coalesce(
                when(platform.arch == "x64", "linux.tar.gz"),
                when(platform.arch == "arm64", "linux-aarch64.tar.gz"),
                when(platform.arch == "arm", "linux-armhf.tar.gz")
            )
        ),
        when(
            platform.is_win,
            coalesce(
                when(platform.arch == "x64", "windows.zip"),
                when(platform.arch == "arm64", "windows-arm64.zip"),
                when(platform.arch == "arm", "windows-arm.zip")
            )
        )
    )

    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://quick-lint-js.com/",
        languages = { "javascript" },
        installer = {
            context.capture(function(ctx)
                local requested_server_version = coalesce(ctx.requested_server_version, "latest")
                local url = "https://c.quick-lint-js.com/releases/%s/manual/%s"

                if platform.is_windows then
                    return std.unzip_remote(url:format(requested_server_version, release_file))
                else
                    return std.untargz_remote(url:format(requested_server_version, release_file))
                end
            end),
            installers.on {
                unix = context.set_working_dir "quick-lint-js",
            },
        },
        default_options = {
            cmd_env = {
                PATH = process.extend_path { path.concat { root_dir, "bin" } },
            },
        },
    }
end