nixos-configuration/users/jrpotter/neovim/config/utils/lsp.lua

28 lines
822 B
Lua
Raw Normal View History

local M = {}
function M.on_attach(client, bufnr)
local function set_nnoremap(key, func)
2024-03-05 03:10:57 +00:00
vim.keymap.set("n", key, func, { buffer = bufnr })
end
2024-03-05 03:10:57 +00:00
set_nnoremap("[d", vim.diagnostic.goto_prev)
set_nnoremap("]d", vim.diagnostic.goto_next)
2023-11-25 17:38:12 +00:00
set_nnoremap('g"', vim.lsp.buf.code_action)
2024-03-05 03:10:57 +00:00
set_nnoremap("g?", vim.diagnostic.open_float)
set_nnoremap("gq", function() vim.lsp.buf.format { async = true } end)
set_nnoremap("gr", vim.lsp.buf.rename)
end
2024-03-05 03:10:57 +00:00
M.capabilities = require("cmp_nvim_lsp").default_capabilities()
function M.setup(client)
-- Return a nested function so that we can continue invoking `setup` in the
-- familiar way.
return function(opts)
opts.on_attach = opts.on_attach or M.on_attach
opts.cabailities = opts.cabailities or M.capabilities
client.setup(opts)
end
end
return M