local wk = require("which-key")
-- Tree
-wk.register({
- ["<leader>e"] = { vim.cmd.NvimTreeToggle, "File Tree" },
- ["<leader>u"] = { vim.cmd.UndotreeToggle, "Undo Tree" },
- ["<leader>i"] = { vim.cmd.InspectTree, "Inspect Tree" },
+wk.add({
+ { "<leader>e", vim.cmd.NvimTreeToggle, desc = "File Tree" },
+ { "<leader>u", vim.cmd.UndotreeToggle, desc = "Undo Tree" },
+ { "<leader>i", vim.cmd.InspectTree, desc = "Inspect Tree" },
})
-- Telescope
-wk.register({
- ["<leader>s"] = { name = "Search" },
- -- ["<leader>sf"] = { telescope.find_files, "Find Files" },
- ["<leader>sf"] = { "<CMD>Telescope frecency workspace=CWD<CR>", "Search Files" },
- ["<leader>ss"] = { telescope.live_grep, "Grep" },
- ["<leader>sg"] = { telescope.grep_string, "Grep String Under Cursor" },
- ["<leader>sM"] = { telescope.man_pages, "Man Pages" },
- ["<leader>sm"] = { telescope.marks, "List Marks" },
- ["<leader>sh"] = { telescope.help_tags, "Help Tags" },
- ["<leader>sb"] = { telescope.buffers, "Buffers" },
- ["<leader>sr"] = { telescope.lsp_references, "References" },
- ["<leader>sG"] = { telescope.git_files, "Find Git Files" },
- ["<leader>sS"] = { telescope.treesitter, "Symbols" },
+wk.add({
+ { "<leader>s", group = "Search" },
+ { "<leader>sf", "<CMD>Telescope frecency workspace=CWD<CR>", desc = "Search Files" },
+ { "<leader>ss", telescope.live_grep, desc = "Grep" },
+ { "<leader>sg", telescope.grep_string, desc = "Grep String Under Cursor" },
+ { "<leader>sM", telescope.man_pages, desc = "Man Pages" },
+ { "<leader>sm", telescope.marks, desc = "List Marks" },
+ { "<leader>sh", telescope.help_tags, desc = "Help Tags" },
+ { "<leader>sb", telescope.buffers, desc = "Buffers" },
+ { "<leader>sr", telescope.lsp_references, desc = "References" },
+ { "<leader>sG", telescope.git_files, desc = "Find Git Files" },
+ { "<leader>sS", telescope.treesitter, desc = "Symbols" },
})
-- LSP Keymaps
-wk.register({
- ["<leader>l"] = { name = "LSP" },
- ["<leader>lD"] = { vim.lsp.buf.declaration, "Goto Declarations" },
- ["<leader>ld"] = { vim.lsp.buf.definition, "Goto Definition" },
- ["<leader>li"] = { vim.lsp.buf.implementation, "Goto Implementation" },
- ["<leader>lh"] = { vim.lsp.buf.hover, "Show Documentation" },
- ["<leader>lr"] = { vim.lsp.buf.rename, "Rename" },
- ["<leader>lR"] = { telescope.lsp_references, "Goto References" },
- ["<leader>la"] = { vim.lsp.buf.code_action, "Code Action" },
- ["<leader>lf"] = { vim.lsp.buf.format, "Format Code" },
+wk.add({
+ { "<leader>l", group = "LSP" },
+ { "<leader>lD", vim.lsp.buf.declaration, desc = "Goto Declarations" },
+ { "<leader>ld", vim.lsp.buf.definition, desc = "Goto Definition" },
+ { "<leader>li", vim.lsp.buf.implementation, desc = "Goto Implementation" },
+ { "<leader>lh", vim.lsp.buf.hover, desc = "Show Documentation" },
+ { "<leader>lr", vim.lsp.buf.rename, desc = "Rename" },
+ { "<leader>lR", telescope.lsp_references, desc = "Goto References" },
+ { "<leader>la", vim.lsp.buf.code_action, desc = "Code Action" },
+ { "<leader>lf", vim.lsp.buf.format, desc = "Format Code" },
})
-wk.register({
- ["<leader>d"] = { name = "Diagnostics" },
- ["<leader>df"] = { vim.diagnostic.open_float(), "Show Diagnostics in Line" },
- ["<leader>dp"] = { function() vim.diagnostic.goto_prev({ border = "rounded" }) end, "Goto Prev Diagnostic" },
- ["<leader>dn"] = { function() vim.diagnostic.goto_next({ border = "rounded" }) end, "Goto Next Diagnostic" },
- ["<leader>da"] = { telescope.diagnostics, "Show Open Diagnostics" },
+wk.add({
+ { "<leader>d", group = "Diagnostics" },
+ { "<leader>df", vim.diagnostic.open_float(), desc = "Show Diagnostics in Line" },
+ { "<leader>dp", function() vim.diagnostic.goto_prev({ border = "rounded" }) end, desc = "Goto Prev Diagnostic" },
+ { "<leader>dn", function() vim.diagnostic.goto_next({ border = "rounded" }) end, desc = "Goto Next Diagnostic" },
+ { "<leader>da", telescope.diagnostics, desc = "Show Open Diagnostics" },
-- ["<leader>da"] = { vim.diagnostic.setloclist(), "Show All Diagnostics in Buffer" },
})
nnoremap("gD", vim.lsp.buf.declaration)
-- Gitsigns
local gs = require("gitsigns")
-wk.register({
- ["<leader>g"] = { name = "Git" },
- ["<leader>gj"] = { gs.next_hunk, "Next Hunk" },
- ["<leader>gk"] = { gs.prev_hunk, "Prev Hunk" },
- ["<leader>gs"] = { function() gs.stage_hunk { vim.fn.line("."), vim.fn.line("v") } end, "Stage Hunk" },
- ["<leader>gr"] = { function() gs.reset_hunk { vim.fn.line("."), vim.fn.line("v") } end, "Reset Hunk" },
- ["<leader>gp"] = { gs.preview_hunk, "Preview Hunk" },
- ["<leader>gu"] = { gs.undo_stage_hunk, "Undo Stage Hunk" },
- ["<leader>gS"] = { gs.stage_buffer, "Stage Buffer" },
- ["<leader>gb"] = { function() gs.blame_line { vim.fn.line("."), vim.fn.line("v") } end, "Blame Line" },
- ["<leader>gB"] = { gs.toggle_current_line_blame, "Toggle Blame Line" },
- ["<leader>gR"] = { gs.reset_buffer, "Reset Buffer" },
- ["<leader>gd"] = { gs.diffthis, "Diff" },
- ["<leader>gD"] = { function() gs.diffthis("~") end, "Diff2" },
- ["<leader>gx"] = { gs.toggle_deleted, "Toggle Deleted" },
- ["<leader>gc"] = { telescope.git_bcommits, "Buffer Commits" },
- ["<leader>gC"] = { telescope.git_commits, "Commits" },
- ["<leader>gn"] = { telescope.git_branches, "Branches" },
+wk.add({
+ { "<leader>g", group = "Git" },
+ { "<leader>gj", gs.next_hunk, desc = "Next Hunk" },
+ { "<leader>gk", gs.prev_hunk, desc = "Prev Hunk" },
+ { "<leader>gs", function() gs.stage_hunk { vim.fn.line("."), vim.fn.line("v") } end, desc = "Stage Hunk" },
+ { "<leader>gr", function() gs.reset_hunk { vim.fn.line("."), vim.fn.line("v") } end, desc = "Reset Hunk" },
+ { "<leader>gp", gs.preview_hunk, desc = "Preview Hunk" },
+ { "<leader>gu", gs.undo_stage_hunk, desc = "Undo Stage Hunk" },
+ { "<leader>gS", gs.stage_buffer, desc = "Stage Buffer" },
+ { "<leader>gb", function() gs.blame_line { vim.fn.line("."), vim.fn.line("v") } end, desc = "Blame Line" },
+ { "<leader>gB", gs.toggle_current_line_blame, desc = "Toggle Blame Line" },
+ { "<leader>gR", gs.reset_buffer, desc = "Reset Buffer" },
+ { "<leader>gd", gs.diffthis, desc = "Diff" },
+ { "<leader>gD", function() gs.diffthis("~") end, desc = "Diff2" },
+ { "<leader>gx", gs.toggle_deleted, desc = "Toggle Deleted" },
+ { "<leader>gc", telescope.git_bcommits, desc = "Buffer Commits" },
+ { "<leader>gC", telescope.git_commits, desc = "Commits" },
+ { "<leader>gn", telescope.git_branches, desc = "Branches" },
})
-- -- Text object
-- map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")