summaryrefslogtreecommitdiff
path: root/after/lsp/emmylua_ls.lua
blob: 4e0cd887ed021f3458ee151caf5eda9361c046b0 (plain)
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
return {
    cmd = { vim.env.XDG_DATA_HOME .. "/cargo/bin/emmylua_ls" },
    filetypes = { "lua" },
    root_markers = {
        ".emmyrc.json",
    },
    workspace_required = false,
    on_init = function(client)
        if client.workspace_folders then
            local path = client.workspace_folders[1].name
            if
                path ~= vim.fn.stdpath("config")
                and (
                    vim.uv.fs_stat(path .. "/.luarc.json")
                    or vim.uv.fs_stat(path .. "/.luarc.jsonc")
                    or vim.uv.fs_stat(path .. "/.emmyrc.jsonc")
                )
            then
                return
            end
        end

        client.config.settings.Lua.workspace =
            vim.tbl_deep_extend("force", client.config.settings.Lua.workspace, {
                library = vim.api.nvim_get_runtime_file("", true),
            })
    end,
    settings = { Lua = { workspace = {} } },
}