aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-lspconfig/server_configurations/angularls/init.lua
blob: de655a40d30a6d775288b9307a19812b6a3fa370 (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 platform = require "mason-core.platform"
local npm = require "mason-core.managers.npm"
local _ = require "mason-core.functional"
local path = require "mason-core.path"

---@param install_dir string
return function(install_dir)
    local append_node_modules = _.map(function(dir)
        return path.concat { dir, "node_modules" }
    end)

    local function get_cmd(workspace_dir)
        local cmd = {
            "ngserver",
            "--stdio",
            "--tsProbeLocations",
            table.concat(append_node_modules { install_dir, workspace_dir }, ","),
            "--ngProbeLocations",
            table.concat(
                append_node_modules {
                    path.concat { install_dir, "node_modules", "@angular", "language-server" },
                    workspace_dir,
                },
                ","
            ),
        }
        if platform.is_win then
            cmd[1] = vim.fn.exepath(cmd[1])
        end

        return cmd
    end

    return {
        cmd = get_cmd(vim.loop.cwd()),
        cmd_env = npm.env(install_dir),
        on_new_config = function(new_config, root_dir)
            new_config.cmd = get_cmd(root_dir)
        end,
    }
end