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

return function(name, root_dir)
    local erlang_ls_file_ext = platform.is_win and ".cmd" or ""
    return server.Server:new {
        name = name,
        root_dir = root_dir,
        languages = { "erlang" },
        homepage = "https://erlang-ls.github.io/",
        installer = {
            std.ensure_executables {
                { "rebar3", "rebar3 was not found in path. Refer to http://rebar3.org/docs/." },
            },
            context.use_github_release "erlang-ls/erlang_ls",
            std.git_clone "https://github.com/erlang-ls/erlang_ls.git",
            function(_, callback, ctx)
                local c = process.chain {
                    cwd = ctx.install_dir,
                    stdio_sink = ctx.stdio_sink,
                }
                local rebar3 = platform.is_win and "rebar3.cmd" or "rebar3"
                c.run(rebar3, { "escriptize" })
                c.run(rebar3, { "as", "dap", "escriptize" })
                c.spawn(callback)
            end,
        },
        default_options = {
            cmd = { path.concat { root_dir, "_build", "default", "bin", ("erlang_ls%s"):format(erlang_ls_file_ext) } },
        },
    }
end