config/.config/nvim/lua/lazyvim/plugins/whichkey.lua

137 lines
5.4 KiB
Lua

return {
{
"folke/which-key.nvim",
event = "BufEnter",
config = function()
local whichkey = require("which-key")
whichkey.setup({
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
spelling = {
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
},
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion
motions = true, -- adds help for motions
text_objects = true, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true, -- bindings for prefixed with g
},
},
key_labels = {
-- override the label used to display some keys. It doesn't effect WK in any other way.
["<leader>"] = "SPC",
},
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 = "<C-d>", -- binding to scroll down inside the popup
scroll_up = "<C-u>", -- binding to scroll up inside the popup
},
window = {
border = "rounded", -- 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 = "center", -- align columns left, center or right
},
ignore_missing = true, -- enable this to hide mappings for which you didn't specify a label
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
show_help = false, -- show help message on the command line when the popup is visible
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" },
},
})
local leader_opts = {
mode = { "n", "v" }, -- NORMAL/VISUAL mode
buffer = nil, -- Global mappings
prefix = "<leader>",
silent = true, -- use 'silent'
noremap = true, -- use 'noremap'
nowait = true, -- use 'nowait'
}
whichkey.register({
mode = { "n", "v" },
["g"] = { name = "+goto" },
["m"] = { name = "+harpoon" },
})
local leader_mappings = {
l = { name = "+lsp" },
b = { name = "+buffer" },
r = { name = "+replace" },
f = { name = "+file" },
s = { name = "+search" },
h = { name = "+help" },
g = { name = "+git" },
t = { name = "+todo" },
N = { name = "+noice" },
o = { name = "+option" },
H = { "<cmd>split<cr>", "split" },
V = { "<cmd>vsplit<cr>", "vsplit" },
n = { "<cmd>NvimTreeToggle<cr>", "Explorer" },
P = { "<cmd>!opout %<cr><cr>", "Preview Document" },
q = { '<cmd>lua require("lazyvim.functions").smart_quit()<CR>', "Quit" },
w = { "<cmd>w<CR>", "Write" },
z = { "<cmd>ZenMode<cr>", "Zen" },
["'"] = { "<cmd>close<CR>", "Close split" },
u = { "<cmd>UndotreeToggle<cr>", "Undo Tree" },
C = {
name = "Compiler",
c = { "<cmd>w! | !compiler %<cr>", "Compile File" },
b = { "<cmd>w! | !pandoc % -t beamer -o presentation.pdf<cr>", "Beamer Presentation" },
},
-- o = {
-- name = "Options",
-- c = { "<cmd>lua vim.g.cmp_active=false<cr>", "Completion off" },
-- C = { "<cmd>lua vim.g.cmp_active=true<cr>", "Completion on" },
-- w = { '<cmd>lua require("user.functions").toggle_option("wrap")<cr>', "Wrap" },
-- r = { '<cmd>lua require("user.functions").toggle_option("relativenumber")<cr>', "Relative" },
-- l = { '<cmd>lua require("user.functions").toggle_option("cursorline")<cr>', "Cursorline" },
-- s = { '<cmd>lua require("user.functions").toggle_option("spell")<cr>', "Spell" },
-- t = { '<cmd>lua require("user.functions").toggle_tabline()<cr>', "Tabline" },
-- },
-- d = {
-- name = "Debug",
-- b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Breakpoint" },
-- c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
-- i = { "<cmd>lua require'dap'.step_into()<cr>", "Into" },
-- o = { "<cmd>lua require'dap'.step_over()<cr>", "Over" },
-- O = { "<cmd>lua require'dap'.step_out()<cr>", "Out" },
-- r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Repl" },
-- l = { "<cmd>lua require'dap'.run_last()<cr>", "Last" },
-- u = { "<cmd>lua require'dapui'.toggle()<cr>", "UI" },
-- x = { "<cmd>lua require'dap'.terminate()<cr>", "Exit" },
-- },
}
whichkey.register(leader_mappings, leader_opts)
end,
},
}