aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua
blob: 696679b06d7fbc57a98417959c6c0f52dc7139c9 (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
45
46
47
48
49
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local platform = require "nvim-lsp-installer.platform"
local Data = require "nvim-lsp-installer.data"
local std = require "nvim-lsp-installer.installers.std"

local root_dir = server.get_server_root_path "sumneko_lua"

local bin_dir = Data.coalesce(
    Data.when(platform.is_mac, "macOS"),
    Data.when(platform.is_unix, "Linux"),
    Data.when(platform.is_win, "Windows")
)

return server.Server:new {
    name = "sumneko_lua",
    root_dir = root_dir,
    installer = {
        std.unzip_remote "https://github.com/sumneko/vscode-lua/releases/download/v2.3.6/lua-2.3.6.vsix",
        -- see https://github.com/sumneko/vscode-lua/pull/43
        std.chmod(
            "+x",
            { "extension/server/bin/macOS/lua-language-server", "extension/server/bin/Linux/lua-language-server" }
        ),
    },
    default_options = {
        cmd = {
            path.concat { root_dir, "extension", "server", "bin", bin_dir, "lua-language-server" },
            "-E",
            path.concat { root_dir, "extension", "server", "main.lua" },
        },
        settings = {
            Lua = {
                diagnostics = {
                    -- Get the language server to recognize the `vim` global
                    globals = { "vim" },
                },
                workspace = {
                    -- Make the server aware of Neovim runtime files
                    library = {
                        [vim.fn.expand "$VIMRUNTIME/lua"] = true,
                        [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
                    },
                    maxPreload = 10000,
                },
            },
        },
    },
}