gabrielgio.lua @ fb3c96d50d625db725940625120012c75afc17f6

 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.lua_ls.setup,
38    lsp_config.pylsp.setup
39})
40
41lsp_config.gopls.setup({
42    capabilities = capabilities,
43    cmd_env = {GOFLAGS = "-tags=unit,integration,e2e"},
44    on_attach = on_attach
45})