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
50
51
52
53
54
55
56
57
|
local lsp_config = require("lspconfig")
local function set_key(mode, keys, v, opts)
return vim.keymap.set(mode, keys, v, opts)
end
local function on_attach(client, bufnr)
do
local bufopts = { noremap = true, silent = true, buffer = bufnr }
set_key("n", "gD", vim.lsp.buf.declaration, bufopts)
set_key("n", "gd", vim.lsp.buf.definition, bufopts)
set_key("n", "K", vim.lsp.buf.hover, bufopts)
set_key("n", "gi", vim.lsp.buf.implementation, bufopts)
set_key("n", "<C-s>", vim.lsp.buf.signature_help, bufopts)
set_key("n", "<space>rn", vim.lsp.buf.declaration, bufopts)
set_key("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
set_key("n", "<space>f", vim.lsp.buf.formatting, bufopts)
end
return bufnr
end
local function setup(f)
return f({ on_attach = on_attach })
end
local function load_all(l)
for _, v in ipairs(l) do
setup(v)
end
return nil
end
load_all({
lsp_config.rust_analyzer.setup,
lsp_config.clangd.setup,
lsp_config.cssls.setup,
lsp_config.html.setup,
lsp_config.emmet_ls.setup,
lsp_config.pylsp.setup,
lsp_config.zls.setup,
lsp_config.tsserver.setup,
})
lsp_config.gopls.setup({
cmd_env = { GOFLAGS = "-tags=unit,integration,e2e" },
on_attach = on_attach,
})
lsp_config.lua_ls.setup({
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
})
|