From 77e283bd9c33166937756250918b12e349caf050 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 2 Aug 2021 23:42:56 +0200 Subject: [Refactor] Allow editing default keymaps (#1213) --- lua/lsp/init.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lua/lsp/init.lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 3373ac46..b85dfcd2 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -33,6 +33,24 @@ local function lsp_highlight_document(client) end end +local function add_lsp_buffer_keybindings(bufnr) + local wk = require "which-key" + local keys = { + ["K"] = { "lua vim.lsp.buf.hover()", "Show hover" }, + ["gd"] = { "lua vim.lsp.buf.definition()", "Goto Definition" }, + ["gD"] = { "lua vim.lsp.buf.declaration()", "Goto declaration" }, + ["gr"] = { "lua vim.lsp.buf.references()", "Goto references" }, + ["gi"] = { "lua vim.lsp.buf.implementation()", "Goto implementation" }, + ["gs"] = { "lua vim.lsp.buf.signature_help()", "show signature help" }, + ["gp"] = { "lua require'lsp.peek'.Peek('definition')", "Peek definition" }, + ["gl"] = { + "lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })", + "Show line diagnostics", + }, + } + wk.register(keys, { mode = "n", buffer = bufnr }) +end + function M.common_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true @@ -64,6 +82,7 @@ function M.common_on_attach(client, bufnr) lvim.lsp.on_attach_callback(client, bufnr) end lsp_highlight_document(client) + add_lsp_buffer_keybindings(bufnr) require("lsp.null-ls").setup(vim.bo.filetype) end -- cgit v1.2.3