From bd8d93e121c0d6e41485cf9758fc746227ba5a49 Mon Sep 17 00:00:00 2001 From: Warwick New Date: Mon, 25 Nov 2024 13:58:16 +0000 Subject: [PATCH] updated whichkey to new spec --- lua/core/plugin_config/whichkey.lua | 166 ++++++++++++---------------- 1 file changed, 73 insertions(+), 93 deletions(-) diff --git a/lua/core/plugin_config/whichkey.lua b/lua/core/plugin_config/whichkey.lua index 7b7c50a..f64dfec 100644 --- a/lua/core/plugin_config/whichkey.lua +++ b/lua/core/plugin_config/whichkey.lua @@ -1,98 +1,78 @@ local whichkey = require("which-key") --- TODO fix based instructions -local keymap = { - t = 'Toggle Terminal', - l = { - name = '+lsp', - e = { "lua vim.diagnostic.open_float()", 'Diagnostic Float' }, - n = { "lua vim.diagnostic.goto_next()", 'Next Diagnostic' }, - N = { "lua vim.diagnostic.goto_prev()", 'Previous Diagnostic' }, - j = { "lua vim.diagnostic.setloclist()", 'Diagnostic List' }, - --- Dynamic to each buffer potential TODO? - D = { "lua vim.lsp.buf.declaration()", 'Declaration' }, - d = { "lua vim.lsp.buf.definition()", 'Definition' }, - k = { "lua vim.lsp.buf.hover()", 'Hover' }, - i = { "lua vim.lsp.buf.implementation()", 'Implementation' }, - t = { "lua vim.lsp.buf.type_definition()", 'Type Definition' }, - R = { "lua vim.lsp.buf.rename()", 'Rename' }, - a = { "lua vim.lsp.buf.code_action()", 'Code Action' }, - r = { "lua vim.lsp.buf.references()", 'References' }, - f = { function() vim.lsp.buf.format { async = true } end, 'Format' }, - }, - f = { - name = '+find (telescope)', - f = { "Telescope find_files", 'Find' }, - o = { "Telescope oldfiles", 'Old Files' }, - g = { "Telescope live_grep", 'Grep' }, - h = { "Telescope help_tags", 'Help Tags' }, - }, - g = { - name = '+git', - l = { 'LazyGit', 'Commits' }, - g = { 'Telescope git_commits', 'LazyGit' }, - b = { 'Telescope git_branches', 'Branches' }, - s = { 'Telescope git_status', 'Status' }, - }, - T = { - name = '+todo', - j = { 'TodoLocList', 'List TODO:\'s in buffer' }, - T = { 'TodoTelescope', 'Search TODO:\'s' }, - n = { function() require("todo-comments").jump_next() end, 'Jump to next TODO:' }, - N = { function() require("todo-comments").jump_prev() end, 'Jump to previous TODO:' }, - }, - w = { - name = '+window', - w = 'Pick Window', - s = "Split window", - v = "Split window vertically", - q = "Quit a window", - T = "Break out into a new tab", - x = "Swap current with next", - ["-"] = "Decrease height", - ["+"] = "Increase height", - [""] = "Decrease width", - [">"] = "Increase width", - ["|"] = "Max out the width", - ["="] = "Equally high and wide", - h = "Go to the left window", - l = "Go to the right window", - k = "Go to the up window", - j = "Go to the down window", - }, - o = { - name = '+org mode', - }, - m = { - 'DarkLightSwitch', 'Toggle dark mode' - }, - v = { - name = '+obsidian Vault', - i = { 'e ~/Sync/wiki/index.md', 'Open Index' }, - o = { 'ObsidianOpen', 'Obsidian Open' }, - n = { 'ObsidianNew', 'New Note' }, - q = { 'ObsidianQuickSwitch', 'Quick Switch with fzf' }, - f = { 'ObsidianFollowLink', 'Follow Link' }, - b = { 'ObsidianBacklinks', 'List Backlinks' }, - d = { 'ObsidianToday', 'Open Daily Note' }, - y = { 'ObsidianYesterday', 'Open Yesterdays Note' }, - t = { 'ObsidianTomorrow', 'Open Tomorrows Note' }, - T = { 'ObsidianTemplate', 'Open Template' }, - s = { 'ObsidianSearch', 'Search Notes' }, - l = { 'ObsidianLink', 'Link Current Selection' }, - L = { 'ObsidianLinkNew', 'Link New Note from Current Selection' }, - w = { 'ObsidianWorkspace', 'Switch Workspace' }, - p = { 'ObsidianPasteImg', 'Paste Image' }, - r = { 'ObsidianRename', 'Rename Note' }, - }, - d = { - name = 'DAP debug tools', - c = { function() require('dap').continue() end, 'continue/launch' }, - o = { function() require('dap').step_over() end, 'continue/launch' }, - i = { function() require('dap').step_into() end, 'continue/launch' }, - b = { function() require('dap').toggle_breakpoint() end, 'continue/launch' }, +local keymap = { + { "T", group = "todo" }, + { "TN", function() require("todo-comments").jump_prev() end, desc = "Jump to previous TODO:" }, + { "TT", "TodoTelescope", desc = "Search TODO:'s" }, + { "Tj", "TodoLocList", desc = "List TODO:'s in buffer" }, + { "Tn", function() require("todo-comments").jump_next() end, desc = "Jump to next TODO:" }, + { "d", group = "DAP debug tools" }, + { "db", function() require('dap').toggle_breakpoint() end, desc = "continue/launch" }, + { "dc", function() require('dap').continue() end, desc = "continue/launch" }, + { "di", function() require('dap').step_into() end, desc = "continue/launch" }, + { "do", function() require('dap').step_over() end, desc = "continue/launch" }, + { "f", group = "find (telescope)" }, + { "ff", "Telescope find_files", desc = "Find" }, + { "fg", "Telescope live_grep", desc = "Grep" }, + { "fh", "Telescope help_tags", desc = "Help Tags" }, + { "fo", "Telescope oldfiles", desc = "Old Files" }, + { "g", group = "git" }, + { "gb", "Telescope git_branches", desc = "Branches" }, + { "gg", "Telescope git_commits", desc = "LazyGit" }, + { "gl", "LazyGit", desc = "Commits" }, + { "gs", "Telescope git_status", desc = "Status" }, + { "l", group = "lsp" }, + { "lD", "lua vim.lsp.buf.declaration()", desc = "Declaration" }, + { "lN", "lua vim.diagnostic.goto_prev()", desc = "Previous Diagnostic" }, + { "lR", "lua vim.lsp.buf.rename()", desc = "Rename" }, + { "la", "lua vim.lsp.buf.code_action()", desc = "Code Action" }, + { "ld", "lua vim.lsp.buf.definition()", desc = "Definition" }, + { "le", "lua vim.diagnostic.open_float()", desc = "Diagnostic Float" }, + { "lf", function() vim.lsp.buf.format { async = true } end, desc = "Format" }, + { "li", "lua vim.lsp.buf.implementation()", desc = "Implementation" }, + { "lj", "lua vim.diagnostic.setloclist()", desc = "Diagnostic List" }, + { "lk", "lua vim.lsp.buf.hover()", desc = "Hover" }, + { "ln", "lua vim.diagnostic.goto_next()", desc = "Next Diagnostic" }, + { "lr", "lua vim.lsp.buf.references()", desc = "References" }, + { "lt", "lua vim.lsp.buf.type_definition()", desc = "Type Definition" }, + { "m", "DarkLightSwitch", desc = "Toggle dark mode" }, + { "o", group = "org mode" }, + { "t", desc = "Toggle Terminal" }, + { "v", group = "obsidian Vault" }, + { "vL", "ObsidianLinkNew", desc = "Link New Note from Current Selection" }, + { "vT", "ObsidianTemplate", desc = "Open Template" }, + { "vb", "ObsidianBacklinks", desc = "List Backlinks" }, + { "vd", "ObsidianToday", desc = "Open Daily Note" }, + { "vf", "ObsidianFollowLink", desc = "Follow Link" }, + { "vi", "e ~/Sync/wiki/index.md", desc = "Open Index" }, + { "vl", "ObsidianLink", desc = "Link Current Selection" }, + { "vn", "ObsidianNew", desc = "New Note" }, + { "vo", "ObsidianOpen", desc = "Obsidian Open" }, + { "vp", "ObsidianPasteImg", desc = "Paste Image" }, + { "vq", "ObsidianQuickSwitch", desc = "Quick Switch with fzf" }, + { "vr", "ObsidianRename", desc = "Rename Note" }, + { "vs", "ObsidianSearch", desc = "Search Notes" }, + { "vt", "ObsidianTomorrow", desc = "Open Tomorrows Note" }, + { "vw", "ObsidianWorkspace", desc = "Switch Workspace" }, + { "vy", "ObsidianYesterday", desc = "Open Yesterdays Note" }, + { "w", group = "window" }, + { "w+", desc = "Increase height" }, + { "w-", desc = "Decrease height" }, + { "w<", desc = "Decrease width" }, + { "w=", desc = "Equally high and wide" }, + { "w>", desc = "Increase width" }, + { "wT", desc = "Break out into a new tab" }, + { "wh", desc = "Go to the left window" }, + { "wj", desc = "Go to the down window" }, + { "wk", desc = "Go to the up window" }, + { "wl", desc = "Go to the right window" }, + { "wq", desc = "Quit a window" }, + { "ws", desc = "Split window" }, + { "wv", desc = "Split window vertically" }, + { "ww", desc = "Pick Window" }, + { "wx", desc = "Swap current with next" }, + { "w|", desc = "Max out the width" }, } -} -- Map window keys to leader w vim.cmd [[nmap w ]] @@ -105,4 +85,4 @@ whichkey.setup { default_mode = 'n', } -whichkey.register(keymap, { prefix = '' }) +whichkey.add(keymap)