gabrielgio.lua @ a89408d1302e8d5c0216041a1e25a226696608e6

 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({capabilities = capabilities, on_attach = on_attach})
24end
25
26local function load_all(l)
27    for _, v in ipairs(l) do setup(v) end
28    return nil
29end
30
31load_all({
32    lsp_config.rust_analyzer.setup,
33    lsp_config.clangd.setup,
34    lsp_config.cssls.setup,
35    lsp_config.html.setup,
36    lsp_config.emmet_ls.setup,
37    lsp_config.pylsp.setup,
38    lsp_config.zls.setup,
39    lsp_config.tsserver.setup
40})
41
42lsp_config.gopls.setup({
43    capabilities = capabilities,
44    cmd_env = {GOFLAGS = "-tags=unit,integration,e2e"},
45    on_attach = on_attach
46})
47
48lsp_config.lua_ls.setup({
49 settings = {
50    Lua = {
51      diagnostics = {
52        globals = {'vim'}
53      }
54    }
55  }
56})