|
local M = {}
|
|
|
|
local keymap = vim.api.nvim_set_keymap
|
|
local buf_keymap = vim.api.nvim_buf_set_keymap
|
|
|
|
local function keymappings(client, bufnr)
|
|
local opts = { noremap = true, silent = true }
|
|
|
|
-- Key mappings
|
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
|
vim.keymap.set("n", "[e", function () vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR}) end, opts)
|
|
vim.keymap.set("n", "]e", function () vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR}) end, opts)
|
|
|
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
|
vim.keymap.set("n", "K", vim.lsp.buf.code_action, opts)
|
|
vim.keymap.set("n", "<leader>of", vim.diagnostic.open_float, opts)
|
|
|
|
-- if client.resolved_capabilities.document_formatting then
|
|
-- vim.keymap.set("n", "<leader>ff", vim.lsp.buf.formatting, opts)
|
|
-- end
|
|
|
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
|
-- vim.keymap.set("n", "gr", function() vim.lsp.buf.references({ includeDeclaration = false }) end, opts)
|
|
vim.keymap.set("n", "gh", vim.lsp.buf.signature_help, opts)
|
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
|
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts)
|
|
|
|
end
|
|
|
|
function M.setup(client, bufnr)
|
|
keymappings(client, bufnr)
|
|
end
|
|
|
|
return M
|