From 66652a650cfad056d966ac0b978ee28d29a6a016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 9 Apr 2023 19:31:14 +0200 Subject: [PATCH] feat(nvim): improve/add keybinds --- modules/programs/nvim/init.lua | 28 +++++------ modules/programs/nvim/keybinds.lua | 50 ++++++++++++++++++- .../programs/nvim/plugins/telescope-nvim.lua | 21 ++++++-- .../nvim/plugins/telescope-zoxide.lua | 4 +- 4 files changed, 78 insertions(+), 25 deletions(-) diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index 8f97399..17bcb48 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -175,8 +175,6 @@ local on_attach_def = function(_, bufnr) l = { name = "lsp", d = { "Lspsaga show_cursor_diagnostics", "open diagnostic window" }, - n = { "Lspsaga diagnostic_jump_next", "next error" }, - p = { "Lspsaga diagnostic_jump_prev", "prev error" }, c = { "Lspsaga code_action", "code action" }, r = { "Lspsaga rename", "rename" }, i = { "Lspsaga hover_doc ++keep", "show info (sticky)" }, @@ -188,17 +186,6 @@ local on_attach_def = function(_, bufnr) mode = { "n", "v" }, }, }, - w = { - name = "workspace", - a = { vim.lsp.buf.add_workspace_folder, "add workspace folder" }, - r = { vim.lsp.buf.remove_workspace_folder, "remove workspace folder" }, - l = { - function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, - "list workspace folders", - }, - }, t = { name = "toggle", l = { lsp_lines.toggle, "lsp lines" }, @@ -206,9 +193,18 @@ local on_attach_def = function(_, bufnr) }, g = { name = "goto", - d = { "Lspsaga peek_definition", "definition" }, - t = { "Lspsaga peek_type_definition", "type defininition" }, - h = { "Lspsaga lsp_finder", "lsp finder" }, + d = { "Lspsaga peek_definition", "Goto definition" }, + t = { "Lspsaga peek_type_definition", "Goto type defininition" }, + h = { "Lspsaga lsp_finder", "Lsp finder" }, + r = { "Telescope lsp_references", "Goto reference" }, + D = { vim.lsp.buf.declaration, "Goto declaration" }, + I = { "Telescope lsp_implementations", "Goto implementation" }, + }, + ["["] = { + d = { "Lspsaga diagnostic_jump_prev", "Previous diagnostic" }, + }, + ["]"] = { + d = { "Lspsaga diagnostic_jump_next", "Next diagnostic" }, }, }, { buffer = bufnr, silent = true }) end diff --git a/modules/programs/nvim/keybinds.lua b/modules/programs/nvim/keybinds.lua index 52ae2e2..039104d 100644 --- a/modules/programs/nvim/keybinds.lua +++ b/modules/programs/nvim/keybinds.lua @@ -1,7 +1,7 @@ --- buffers +-- buffer require("which-key").register({ b = { - name = "buffers", + name = "buffer", b = { "Telescope buffers", "List buffers" }, d = { "bd", "Delete buffer" }, n = { "bnext", "Next buffer" }, @@ -9,6 +9,52 @@ require("which-key").register({ }, }) +-- window +require("which-key").register({ + w = { + name = "window", + ["|"] = { "v", "Split window horizontally" }, + ["-"] = { "s", "Split window vertically" }, + w = { "w", "Switch window" }, + d = { "c", "Delete window" }, + }, +}, { prefix = "" }) + +-- fast window move +require("which-key").register({ + [""] = { "h", "Move window left" }, + [""] = { "j", "Move window down" }, + [""] = { "k", "Move window up" }, + [""] = { "l", "Move window right" }, +}) + +-- tab +require("which-key").register({ + [""] = { + name = "tab", + [""] = { "tabnew", "New tab" }, + n = { "tabnext", "Next tab" }, + p = { "tabprevious", "Previous tab" }, + d = { "tabclose", "Close tab" }, + }, +}, { prefix = "" }) + +-- file +require("which-key").register({ + f = { + name = "file/find", + n = { "enew", "New file" }, + }, +}, { prefix = "" }) + +-- better descriptions for navigation +require("which-key").register({ + ["["] = { name = "prev" }, + ["]"] = { name = "next" }, + o = { name = "org" }, + x = { name = "diagnostics/quickfix" }, +}) + -- Clear search with require("which-key").register({ [""] = { "noh", "Escape and clear hlsearch", mode = { "n", "i" } }, diff --git a/modules/programs/nvim/plugins/telescope-nvim.lua b/modules/programs/nvim/plugins/telescope-nvim.lua index d83cec4..cfb87c8 100644 --- a/modules/programs/nvim/plugins/telescope-nvim.lua +++ b/modules/programs/nvim/plugins/telescope-nvim.lua @@ -1,9 +1,20 @@ require("which-key").register({ f = { - name = "find", - f = { "Telescope find_files", "find file" }, - l = { "Telescope current_buffer_fuzzy_find", "find line" }, - g = { "Telescope live_grep", "live grep" }, - b = { "Telescope buffers", "find buffer" }, + name = "file/find", + f = { "Telescope find_files", "Find files" }, + b = { "Telescope buffers", "Find buffers" }, + r = { "Telescope oldfiles", "Find recent files" }, + }, + s = { + name = "search", + l = { "Telescope current_buffer_fuzzy_find", "Search lines" }, + g = { "Telescope live_grep", "Live grep" }, + c = { "Telescope command_history", "Command history" }, + C = { "Telescope commands", "Commands" }, + d = { "Telescope diagnostics", "Diagnostics" }, + h = { "Telescope help_tags", "Help tags" }, + k = { "Telescope keymaps", "Keymaps" }, + s = { "Telescope lsp_document_symbols", "Symbols (Document)" }, + S = { "Telescope lsp_workspace_symbols", "Symbols (Workspace)" }, }, }, { prefix = "" }) diff --git a/modules/programs/nvim/plugins/telescope-zoxide.lua b/modules/programs/nvim/plugins/telescope-zoxide.lua index bb8f7f1..cd2c5af 100644 --- a/modules/programs/nvim/plugins/telescope-zoxide.lua +++ b/modules/programs/nvim/plugins/telescope-zoxide.lua @@ -1,7 +1,7 @@ require("telescope").load_extension("zoxide") require("which-key").register({ f = { - name = "find", - z = { "Telescope zoxide list", "find location" }, + name = "file/find", + z = { "Telescope zoxide list", "Find location (Zoxide)" }, }, }, { prefix = "" })