aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/vala_ls/init.lua
blob: 1fca178b492eb67d1e0e6292784b060fb33efe4b (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 server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local std = require "nvim-lsp-installer.core.managers.std"
local github = require "nvim-lsp-installer.core.managers.github"
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" },
        async = true,
        ---@param ctx InstallContext
        installer = function(ctx)
            std.ensure_executable("meson", { help_url = "https://mesonbuild.com/Getting-meson.html" })
            std.ensure_executable("ninja", { help_url = "https://ninja-build.org/" })
            std.ensure_executable("valac", { help_url = "https://wiki.gnome.org/Projects/Vala" })

            local release_source = github.untarxz_release_file {
                repo = "Prince781/vala-language-server",
                asset_file = function(version)
                    return ("vala-language-server-%s.tar.xz"):format(version)
                end,
            }
            release_source.with_receipt()

            local vala_dirname = ("vala-language-server-%s"):format(release_source.release)
            ctx:chdir(vala_dirname, function()
                ctx.spawn.meson { ("-Dprefix=%s"):format(ctx.cwd:get()), "build" }
                ctx.spawn.ninja { "-C", "build", "install" }
            end)
            ctx.fs:rmrf(vala_dirname)
        end,
        default_options = {
            cmd_env = {
                PATH = process.extend_path { path.concat { root_dir, "bin" } },
            },
        },
    }
end