gabrielgio.lua @ 2d94bbee48f6a887e68737ed8d27e3b193618878

 1local lsp_config = require("lspconfig")
 2
 3local function set_key(mode, keys, v, opts)
 4	return vim.keymap.set(mode, keys, v, opts)
 5end
 6
 7local function on_attach(client, bufnr)
 8	do
 9		local bufopts = { noremap = true, silent = true, buffer = bufnr }
10		set_key("n", "gD", vim.lsp.buf.declaration, bufopts)
11		set_key("n", "gd", vim.lsp.buf.definition, bufopts)
12		set_key("n", "K", vim.lsp.buf.hover, bufopts)
13		set_key("n", "gi", vim.lsp.buf.implementation, bufopts)
14		set_key("n", "<C-s>", vim.lsp.buf.signature_help, bufopts)
15		set_key("n", "<space>rn", vim.lsp.buf.declaration, bufopts)
16		set_key("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
17		set_key("n", "<space>f", vim.lsp.buf.formatting, bufopts)
18	end
19	return bufnr
20end
21
22local function setup(f)
23	return f({ on_attach = on_attach })
24end
25
26local function load_all(l)
27	for _, v in ipairs(l) do
28		setup(v)
29	end
30	return nil
31end
32
33load_all({
34	lsp_config.rust_analyzer.setup,
35	lsp_config.clangd.setup,
36	lsp_config.cssls.setup,
37	lsp_config.html.setup,
38	lsp_config.emmet_ls.setup,
39	lsp_config.pylsp.setup,
40	lsp_config.zls.setup,
41	lsp_config.tsserver.setup,
42})
43
44lsp_config.gopls.setup({
45	cmd_env = { GOFLAGS = "-tags=unit,integration,e2e" },
46	on_attach = on_attach,
47})
48
49lsp_config.lua_ls.setup({
50	settings = {
51		Lua = {
52			diagnostics = {
53				globals = { "vim" },
54			},
55		},
56	},
57})