aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/vls/init.lua
blob: 207cb81967a23c3554eebd31ac5d398a9fb06dea (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
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.core.path"
local github = require "nvim-lsp-installer.core.managers.github"
local github_client = require "nvim-lsp-installer.core.managers.github.client"
local std = require "nvim-lsp-installer.core.managers.std"
local functional = require "nvim-lsp-installer.core.functional"
local platform = require "nvim-lsp-installer.core.platform"
local Optional = require "nvim-lsp-installer.core.optional"
local process = require "nvim-lsp-installer.core.process"

return function(name, root_dir)
    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://github.com/vlang/vls",
        languages = { "vlang", "V" },
        ---@async
        installer = function()
            local repo = "vlang/vls"

            ---@type GitHubRelease
            local latest_dev_build =
                github_client.fetch_latest_release(repo, { include_prerelease = true }):get_or_throw()

            local source = github.release_file {
                version = Optional.of(latest_dev_build.tag_name),
                repo = repo,
                asset_file = functional.coalesce(
                    functional.when(platform.is.linux_x64, "vls_linux_x64"),
                    functional.when(platform.is.mac, "vls_macos_x64"),
                    functional.when(platform.is.win_x64, "vls_windows_x64.exe")
                ),
            }
            source.with_receipt()
            std.download_file(source.download_url, platform.is.win and "vls.exe" or "vls")
            std.chmod("+x", { "vls" })
        end,
        default_options = {
            cmd_env = {
                PATH = process.extend_path { root_dir },
            },
        },
    }
end