From adedb42a99c083e4a88d22524796b649ee799827 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 4 Mar 2022 14:23:09 +0100 Subject: [PATCH] home: vim: add mappings for LSP functionality --- home/vim/lua/ambroisie/utils.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/home/vim/lua/ambroisie/utils.lua b/home/vim/lua/ambroisie/utils.lua index e3833cc..559911c 100644 --- a/home/vim/lua/ambroisie/utils.lua +++ b/home/vim/lua/ambroisie/utils.lua @@ -63,6 +63,27 @@ M.on_attach = function(client, bufnr) augroup END ]]) end + + -- Mappings + local wk = require("which-key") + + local keys = { + K = { vim.lsp.buf.hover, "Show symbol information" }, + ["gd"] = { vim.lsp.buf.definition, "Go to definition" }, + ["gD"] = { vim.lsp.buf.declaration, "Go to declaration" }, + ["gi"] = { vim.lsp.buf.implementation, "Go to implementation" }, + ["gr"] = { vim.lsp.buf.references, "List all references" }, + + ["c"] = { + name = "Code", + a = { vim.lsp.buf.code_action, "Code actions" }, + r = { vim.lsp.buf.rename, "Rename symbol" }, + s = { vim.lsp.buf.signature_help, "Show signature" }, + t = { vim.lsp.buf.type_definition, "Go to type definition" }, + }, + } + + wk.register(keys, { buffer = bufnr }) end return M