local M = {} M.config = function() lvim.builtin.which_key = { ---@usage disable which-key completely [not recommended] active = true, on_config_done = nil, setup = { plugins = { marks = false, -- shows a list of your marks on ' and ` registers = false, -- shows your registers on " in NORMAL or in INSERT mode -- the presets plugin, adds help for a bunch of default keybindings in Neovim -- No actual key bindings are created presets = { operators = false, -- adds help for operators like d, y, ... motions = false, -- adds help for motions text_objects = false, -- help for text objects triggered after entering an operator windows = false, -- default bindings on nav = true, -- misc bindings to work with windows z = false, -- bindings for folds, spelling and others prefixed with z g = false, -- bindings for prefixed with g }, spelling = { enabled = true, suggestions = 20 }, -- use which-key for spelling hints }, icons = { breadcrumb = "»", -- symbol used in the command line area that shows your active key combo separator = "➜", -- symbol used between a key and it's label group = "+", -- symbol prepended to a group }, popup_mappings = { scroll_down = "", -- binding to scroll down inside the popup scroll_up = "", -- binding to scroll up inside the popup }, window = { border = "single", -- none, single, double, shadow position = "bottom", -- bottom, top margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] winblend = 0, }, layout = { height = { min = 4, max = 25 }, -- min and max height of the columns width = { min = 20, max = 50 }, -- min and max width of the columns spacing = 3, -- spacing between columns align = "left", -- align columns left, center or right }, hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label show_help = true, -- show help message on the command line when the popup is visible triggers = "auto", -- automatically setup triggers -- triggers = {""} -- or specify a list manually triggers_blacklist = { -- list of mode / prefixes that should never be hooked by WhichKey -- this is mostly relevant for key maps that start with a native binding -- most people should not need to change this i = { "j", "k" }, v = { "j", "k" }, }, }, opts = { mode = "n", -- NORMAL mode prefix = "", 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 }, vopts = { mode = "v", -- VISUAL mode prefix = "", 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 }, -- NOTE: Prefer using : over as the latter avoids going back in normal-mode. -- see https://neovim.io/doc/user/map.html#:map-cmd vmappings = { ["/"] = { "(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" }, }, mappings = { [";"] = { "Alpha", "Dashboard" }, ["w"] = { "w!", "Save" }, ["q"] = { "lua require('lvim.utils.functions').smart_quit()", "Quit" }, ["/"] = { "(comment_toggle_linewise_current)", "Comment toggle current line" }, ["c"] = { "BufferKill", "Close Buffer" }, ["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" }, ["h"] = { "nohlsearch", "No Highlight" }, b = { name = "Buffers", j = { "BufferLinePick", "Jump" }, f = { "Telescope buffers", "Find" }, b = { "BufferLineCyclePrev", "Previous" }, n = { "BufferLineCycleNext", "Next" }, -- w = { "BufferWipeout", "Wipeout" }, -- TODO: implement this for bufferline e = { "BufferLinePickClose", "Pick which buffer to close", }, h = { "BufferLineCloseLeft", "Close all to the left" }, l = { "BufferLineCloseRight", "Close all to the right", }, D = { "BufferLineSortByDirectory", "Sort by directory", }, L = { "BufferLineSortByExtension", "Sort by language", }, }, p = { name = "Packer", c = { "PackerCompile", "Compile" }, i = { "PackerInstall", "Install" }, r = { "lua require('lvim.plugin-loader').recompile()", "Re-compile" }, s = { "PackerSync", "Sync" }, S = { "PackerStatus", "Status" }, u = { "PackerUpdate", "Update" }, }, -- " Available Debug Adapters: -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ -- " Adapter configuration and installation instructions: -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation -- " Debug Adapter protocol: -- " https://microsoft.github.io/debug-adapter-protocol/ -- " Debugging g = { name = "Git", j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, l = { "lua require 'gitsigns'.blame_line()", "Blame" }, 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", }, o = { "Telescope git_status", "Open changed file" }, b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope git_commits", "Checkout commit" }, C = { "Telescope git_bcommits", "Checkout commit(for current file)", }, d = { "Gitsigns diffthis HEAD", "Git Diff", }, }, l = { name = "LSP", a = { "lua vim.lsp.buf.code_action()", "Code Action" }, d = { "Telescope diagnostics bufnr=0 theme=get_ivy", "Buffer Diagnostics" }, w = { "Telescope diagnostics", "Diagnostics" }, f = { require("lvim.lsp.utils").format, "Format" }, i = { "LspInfo", "Info" }, I = { "Mason", "Mason Info" }, j = { vim.diagnostic.goto_next, "Next Diagnostic", }, k = { vim.diagnostic.goto_prev, "Prev Diagnostic", }, l = { vim.lsp.codelens.run, "CodeLens Action" }, q = { vim.diagnostic.setloclist, "Quickfix" }, r = { vim.lsp.buf.rename, "Rename" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols", }, e = { "Telescope quickfix", "Telescope Quickfix" }, }, L = { name = "+LunarVim", c = { "edit " .. get_config_dir() .. "/config.lua", "Edit config.lua", }, f = { "lua require('lvim.core.telescope.custom-finders').find_lunarvim_files()", "Find LunarVim files", }, g = { "lua require('lvim.core.telescope.custom-finders').grep_lunarvim_files()", "Grep LunarVim files", }, k = { "Telescope keymaps", "View LunarVim's keymappings" }, i = { "lua require('lvim.core.info').toggle_popup(vim.bo.filetype)", "Toggle LunarVim Info", }, I = { "lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog()", "View LunarVim's changelog", }, l = { name = "+logs", d = { "lua require('lvim.core.terminal').toggle_log_view(require('lvim.core.log').get_path())", "view default log", }, D = { "lua vim.fn.execute('edit ' .. require('lvim.core.log').get_path())", "Open the default logfile", }, l = { "lua require('lvim.core.terminal').toggle_log_view(vim.lsp.get_log_path())", "view lsp log", }, L = { "lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())", "Open the LSP logfile" }, n = { "lua require('lvim.core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))", "view neovim log", }, N = { "edit $NVIM_LOG_FILE", "Open the Neovim logfile" }, p = { "lua require('lvim.core.terminal').toggle_log_view(get_cache_dir() .. '/packer.nvim.log')", "view packer log", }, P = { "edit $LUNARVIM_CACHE_DIR/packer.nvim.log", "Open the Packer logfile" }, }, n = { "Telescope notify", "View Notifications" }, r = { "LvimReload", "Reload LunarVim's configuration" }, u = { "LvimUpdate", "Update LunarVim" }, }, s = { name = "Search", b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope colorscheme", "Colorscheme" }, f = { "Telescope find_files", "Find File" }, h = { "Telescope help_tags", "Find Help" }, H = { "Telescope highlights", "Find highlight groups" }, M = { "Telescope man_pages", "Man Pages" }, r = { "Telescope oldfiles", "Open Recent File" }, R = { "Telescope registers", "Registers" }, t = { "Telescope live_grep", "Text" }, k = { "Telescope keymaps", "Keymaps" }, C = { "Telescope commands", "Commands" }, p = { "lua require('telescope.builtin').colorscheme({enable_preview = true})", "Colorscheme with Preview", }, }, T = { name = "Treesitter", i = { ":TSConfigInfo", "Info" }, }, }, } end M.setup = function() local which_key = require "which-key" which_key.setup(lvim.builtin.which_key.setup) local opts = lvim.builtin.which_key.opts local vopts = lvim.builtin.which_key.vopts local mappings = lvim.builtin.which_key.mappings local vmappings = lvim.builtin.which_key.vmappings which_key.register(mappings, opts) which_key.register(vmappings, vopts) if lvim.builtin.which_key.on_config_done then lvim.builtin.which_key.on_config_done(which_key) end end return M