aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/vala_ls/init.lua
blob: b3e514311c02bb1594da76d2e1e61dbd47434465 (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
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local std = require "nvim-lsp-installer.installers.std"
local context = require "nvim-lsp-installer.installers.context"
local installers = require "nvim-lsp-installer.installers"
local process = require "nvim-lsp-installer.process"

return function(name, root_dir)
    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://wiki.gnome.org/Projects/Vala",
        languages = { "vala" },
        installer = {
            std.ensure_executables {
                { "meson", "meson was not found in path. Refer to https://mesonbuild.com/Getting-meson.html" },
                { "ninja", "ninja was not found in path. Refer to https://ninja-build.org/" },
                { "valac", "valac was not found in path. Refer to https://wiki.gnome.org/Projects/Vala" },
            },
            context.use_github_release_file("Prince781/vala-language-server", function(version)
                return ("vala-language-server-%s.tar.xz"):format(version)
            end),
            context.capture(function(ctx)
                return installers.pipe {
                    std.untarxz_remote(ctx.github_release_file),
                    std.rename(
                        ("vala-language-server-%s"):format(ctx.requested_server_version),
                        "vala-language-server"
                    ),
                }
            end),
            function(_, callback, ctx)
                local c = process.chain {
                    cwd = path.concat { ctx.install_dir, "vala-language-server" },
                    stdio_sink = ctx.stdio_sink,
                }

                c.run("meson", { ("-Dprefix=%s"):format(ctx.install_dir), "build" })
                c.run("ninja", { "-C", "build", "install" })

                c.spawn(callback)
            end,
            std.rmrf "vala-language-server",
            context.receipt(function(receipt, ctx)
                receipt:with_primary_source(receipt.github_release_file(ctx))
            end),
        },
        default_options = {
            cmd_env = {
                PATH = process.extend_path { path.concat { root_dir, "bin" } },
            },
        },
    }
end