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", "rn", vim.lsp.buf.rename, opts) vim.keymap.set("n", "K", vim.lsp.buf.code_action, opts) vim.keymap.set("n", "of", vim.diagnostic.open_float, opts) if client.resolved_capabilities.document_formatting then vim.keymap.set("n", "ff", vim.lsp.buf.formatting, opts) end vim.keymap.set("n", "d", vim.lsp.buf.definition, opts) vim.keymap.set("n", "D", vim.lsp.buf.declaration, opts) vim.keymap.set("n", "h", vim.lsp.buf.signature_help, opts) vim.keymap.set("n", "i", vim.lsp.buf.implementation, opts) vim.keymap.set("n", "T", vim.lsp.buf.type_definition, opts) end function M.setup(client, bufnr) keymappings(client, bufnr) end return M