aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/hls/init.lua
blob: a154a4f27d846ea0e710c62b7075add1edd91b7f (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
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
local Data = require "nvim-lsp-installer.data"
local github = require "nvim-lsp-installer.core.managers.github"

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

return function(name, root_dir)
    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://haskell-language-server.readthedocs.io/en/latest/",
        languages = { "haskell" },
        async = true,
        ---@param ctx InstallContext
        installer = function(ctx)
            github.untargz_release_file({
                repo = "haskell/haskell-language-server",
                asset_file = function(version)
                    local target = coalesce(
                        when(platform.is_mac, "haskell-language-server-macOS-%s.tar.gz"),
                        when(platform.is_linux, "haskell-language-server-Linux-%s.tar.gz"),
                        when(platform.is_win, "haskell-language-server-Windows-%s.tar.gz")
                    )
                    return target and target:format(version)
                end,
            }).with_receipt()
            if platform.is_unix then
                ctx.spawn.sh { "-c", [[ chmod +x haskell* ]] }
            end
        end,
        default_options = {
            cmd_env = {
                PATH = process.extend_path { root_dir },
            },
        },
    }
end