local status_ok, which_key = pcall(require, "which-key") if not status_ok then return end local opts = { buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings silent = true, -- use `silent` when creating keymaps noremap = true, -- use `noremap` when creating keymaps nowait = true, -- use `nowait` when creating keymaps } local mappings = { -- Ctrl maps [""] = { "w!", "Save" }, [""] = { "NvimTreeToggle", "Explorer" }, } local nopts = { mode = "n", -- NORMAL mode buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings silent = true, -- use `silent` when creating keymaps noremap = true, -- use `noremap` when creating keymaps nowait = true, -- use `nowait` when creating keymaps } local nmappings = { -- Ctrl maps [""] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, -- Prefix "" [""] = { a = { "Alpha", "Alpha" }, c = { "Bdelete!", "Close Buffer" }, q = { "q!", "Quit" }, R = { "lua require('renamer').rename()", "Rename" }, w = { "w!", "Save" }, W = { ":set wrap! linebreak!", "Toggle Line Wrap" }, z = { "ZenMode", "Zen" }, ["/"] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, f = { name = "Find", b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope colorscheme", "Colorscheme" }, C = { "Telescope commands", "Commands" }, e = { "Telescope frecency theme=get_dropdown", "Frecency" }, f = { "Telescope find_files theme=get_dropdown", "Find files" }, g = { "Telescope live_grep theme=ivy", "Find Text" }, h = { "Telescope help_tags", "Help" }, i = { "lua require('telescope').extensions.media_files.media_files()", "Media" }, k = { "Telescope keymaps", "Keymaps" }, l = { "Telescope resume", "Last Search" }, m = { "Telescope man_pages", "Man Pages" }, p = { "lua require('telescope').extensions.projects.projects()", "Projects" }, r = { "Telescope oldfiles", "Recent File" }, R = { "Telescope registers", "Registers" }, t = { "Telescope buffers show_all_buffers=true theme=get_dropdown", "Buffers" }, }, g = { name = "Git", b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope git_commits", "Checkout commit" }, d = { "Gitsigns diffthis HEAD", "Diff" }, g = { "LazyGit", "Lazygit" }, j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, l = { "GitBlameToggle", "Blame" }, o = { "Telescope git_status", "Open changed file" }, p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, u = { "lua require 'gitsigns'.undo_stage_hunk()", "Undo Stage Hunk" }, w = { name = "Worktree", s = { [[lua require('telescope').extensions.git_worktree.git_worktrees()]], "Switch" }, c = { [[lua require('telescope').extensions.git_worktree.create_git_worktree()]], "Create" }, }, }, l = { name = "LSP", a = { "lua vim.lsp.buf.code_action()", "Code Action" }, d = { "TroubleToggle", "Diagnostics" }, f = { "lua vim.lsp.buf.formatting()", "Format" }, -- F = { "LspToggleAutoFormat", "Toggle Autoformat" }, g = { name = "Goto", d = { "lua vim.lsp.buf.definition()", "Definition" }, D = { "lua vim.lsp.buf.declaration()", "Declaration" }, i = { "lua vim.lsp.buf.implementation()", "Implementation" }, r = { "lua vim.lsp.buf.references()", "References" }, }, h = { "lua vim.lsp.buf.hover()", "Hover" }, H = { "lua vim.lsp.buf.signature_help()", "Signature Help" }, i = { "LspInfo", "Info" }, I = { "LspInstallInfo", "Installer Info" }, j = { "lua vim.diagnostic.goto_next({buffer=0})", "Next Diagnostic" }, k = { "lua vim.diagnostic.goto_prev({buffer=0})", "Prev Diagnostic" }, l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, o = { "SymbolsOutline", "Outline" }, q = { "lua vim.lsp.diagnostic.set_loclist()", "Quickfix" }, r = { "lua vim.lsp.buf.rename()", "Rename" }, R = { "TroubleToggle lsp_references", "References" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols" }, w = { "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics" }, }, p = { name = "Packer", c = { "PackerCompile", "Compile" }, i = { "PackerInstall", "Install" }, s = { "PackerSync", "Sync" }, S = { "PackerStatus", "Status" }, u = { "PackerUpdate", "Update" }, }, r = { name = "Replace", f = { "lua require('spectre').open_file_search()", "Replace Buffer" }, r = { "lua require('spectre').open()", "Replace" }, w = { "lua require('spectre').open_visual({select_word=true})", "Replace Word" }, }, s = { name = "Surround", ["."] = { "lua require('surround').repeat_last()", "Repeat" }, a = { "lua require('surround').surround_add(true)", "Add" }, b = { "lua require('surround').toggle_brackets()", "Brackets" }, d = { "lua require('surround').surround_delete()", "Delete" }, q = { "lua require('surround').toggle_quotes()", "Quotes" }, r = { "lua require('surround').surround_replace()", "Replace" }, }, t = { name = "Terminal", ["1"] = { ":1ToggleTerm", "1" }, ["2"] = { ":2ToggleTerm", "2" }, ["3"] = { ":3ToggleTerm", "3" }, ["4"] = { ":4ToggleTerm", "4" }, f = { "ToggleTerm direction=float", "Float" }, h = { "ToggleTerm size=10 direction=horizontal", "Horizontal" }, v = { "ToggleTerm size=80 direction=vertical", "Vertical" }, }, T = { name = "Treesitter", h = { "TSHighlightCapturesUnderCursor", "Highlight" }, p = { "TSPlaygroundToggle", "Playground" }, }, }, -- Prefix "m" m = { a = { "BookmarkAnnotate", "Annotate" }, c = { "BookmarkClear", "Clear" }, h = { 'lua require("harpoon.mark").add_file()', "Harpoon" }, j = { "BookmarkNext", "Next" }, k = { "BookmarkPrev", "Prev" }, m = { "BookmarkToggle", "Toggle" }, s = { "lua require('telescope').extensions.vim_bookmarks.all({ hide_filename=false, prompt_title=\"bookmarks\", shorten_path=false })", "Show", }, u = { 'lua require("harpoon.ui").toggle_quick_menu()', "Harpoon UI" }, x = { "BookmarkClearAll", "Clear All" }, }, } local vopts = { mode = "v", -- VISUAL mode buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings silent = true, -- use `silent` when creating keymaps noremap = true, -- use `noremap` when creating keymaps nowait = true, -- use `nowait` when creating keymaps } local vmappings = { -- Ctrl maps [""] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, -- Prefix "" [""] = { ["/"] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, } } which_key.register(mappings, opts) which_key.register(nmappings, nopts) which_key.register(vmappings, vopts)