2023-11-20 15:02:47 +00:00
|
|
|
local M = {}
|
|
|
|
|
2023-12-03 19:54:43 +00:00
|
|
|
function M.on_attach(client, bufnr)
|
2023-11-24 15:59:59 +00:00
|
|
|
local function set_nnoremap(key, func)
|
2024-03-05 03:10:57 +00:00
|
|
|
vim.keymap.set("n", key, func, { buffer = bufnr })
|
2023-11-24 15:59:59 +00:00
|
|
|
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)
|
2023-11-20 15:02:47 +00:00
|
|
|
end
|
|
|
|
|
2024-03-05 03:10:57 +00:00
|
|
|
M.capabilities = require("cmp_nvim_lsp").default_capabilities()
|
2023-11-20 15:02:47 +00:00
|
|
|
|
|
|
|
function M.setup(client)
|
|
|
|
-- Return a nested function so that we can continue invoking `setup` in the
|
|
|
|
-- familiar way.
|
|
|
|
return function(opts)
|
2023-12-03 19:54:43 +00:00
|
|
|
opts.on_attach = opts.on_attach or M.on_attach
|
|
|
|
opts.cabailities = opts.cabailities or M.capabilities
|
2023-11-20 15:02:47 +00:00
|
|
|
client.setup(opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|