aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/verible/init.lua
blob: 6673deffc6a6d0c784d387336cffb66fdfdbb006 (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
66
67
68
69
70
71
72
73
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.core.process"
local platform = require "nvim-lsp-installer.core.platform"
local functional = require "nvim-lsp-installer.core.functional"
local path = require "nvim-lsp-installer.core.path"
local github = require "nvim-lsp-installer.core.managers.github"

local coalesce, when = functional.coalesce, functional.when

return function(name, root_dir)
    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://chipsalliance.github.io/verible/",
        languages = { "systemverilog", "verilog" },
        ---@param ctx InstallContext
        installer = function(ctx)
            local repo = "chipsalliance/verible"
            platform.when {
                linux = function()
                    local os_dist = platform.os_distribution()
                    local source = github.untarxz_release_file {
                        repo = repo,
                        asset_file = function(release)
                            if os_dist.id == "ubuntu" then
                                local target_file = when(
                                    platform.arch == "x64",
                                    coalesce(
                                        when(
                                            os_dist.version.major == 16,
                                            "verible-%s-Ubuntu-16.04-xenial-x86_64.tar.gz"
                                        ),
                                        when(
                                            os_dist.version.major == 18,
                                            "verible-%s-Ubuntu-18.04-bionic-x86_64.tar.gz"
                                        ),
                                        when(os_dist.version.major == 20, "verible-%s-Ubuntu-20.04-focal-x86_64.tar.gz"),
                                        when(os_dist.version.major == 22, "verible-%s-Ubuntu-22.04-jammy-x86_64.tar.gz")
                                    )
                                )
                                return target_file and target_file:format(release)
                            end
                        end,
                    }
                    source.with_receipt()
                    ctx.fs:rename(("verible-%s"):format(source.release), "verible")
                end,
                win = function()
                    local source = github.unzip_release_file {
                        repo = repo,
                        asset_file = function(release)
                            local target_file = coalesce(when(platform.arch == "x64", "verible-%s-win64.zip"))
                            return target_file and target_file:format(release)
                        end,
                    }
                    source.with_receipt()
                    ctx.fs:rename(("verible-%s-win64"):format(source.release), "verible")
                end,
            }
        end,
        default_options = {
            cmd_env = {
                PATH = process.extend_path {
                    path.concat(coalesce(
                        when(platform.is_win, { root_dir, "verible" }),
                        when(platform.is_unix, { root_dir, "verible", "bin" }),
                        { root_dir, "verible", "bin" } -- default
                    )),
                },
            },
        },
    }
end