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

248 lines
7.2 KiB
Lua

return {
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
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?
},
},
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
},
},
config = function(_, opts)
local whichkey = require("which-key")
local utils = require("lazyvim.utils")
whichkey.setup(opts)
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" },
["]"] = { name = "+next" },
["["] = { name = "+previous" },
})
local leader_mappings = {
b = { name = "+buffer" },
r = { name = "+replace" },
s = { name = "+search" },
h = { name = "+help" },
gh = { name = "+hunks" },
t = { name = "+todo" },
N = { name = "+noice" },
e = { "<cmd>NvimTreeToggle<cr>", "Explorer" },
Z = { "<cmd>ZenMode<cr>", "Zen" },
u = { "<cmd>UndotreeToggle<cr>", "Undo Tree" },
["'"] = { "<cmd>close<CR>", "Close split" },
n = {
name = "+neorg",
n = { "<cmd>Neorg<cr>", "Open Neorg" },
c = { "<cmd>Neorg toggle-concealer<cr>", "Toggle Concealer" },
t = { "<cmd>Neorg tangle current-file<cr>", "Tangle Current File" },
j = { "<cmd>Neorg journal<cr>", "Open Neorg Journal" },
w = {
function()
require("lazyvim.utils.neorg").workspace_switcher()
end,
"Workspace Switcher",
},
},
f = {
name = "+file",
n = { "<cmd>enew<cr>", "New File" },
},
q = {
name = "+quit",
q = { "<cmd>wq<CR>", "Save and Quit Current" },
a = { "<cmd>wqa<cr>", "Save and Quit all" },
},
l = {
name = "+lsp",
l = { "<cmd>lopen<cr>", "Open Location List" },
q = { "<cmd>copen<cr>", "Open Quickfix List" },
},
c = {
name = "Compiler",
c = { "<cmd>w! | !compiler %<cr>", "Compile File" },
b = { "<cmd>w! | !pandoc % -t beamer -o presentation.pdf<cr>", "Beamer Presentation" },
p = { "<cmd>!opout %<cr><cr>", "Preview Document" },
},
w = {
name = "+window",
w = { "<C-W>p", "Other window" },
d = { "<C-W>c", "Delete Window" },
h = { "<C-W>s", "Split Below" },
v = { "<C-W>v", "Split Right" },
},
o = {
name = "+option",
f = {
function()
require("lazyvim.plugins.lsp.format").toggle()
end,
"Toggle format on save",
},
s = {
function()
utils.toggle("spell")
end,
"Toggle spelling",
},
w = {
function()
utils.toggle("wrap")
end,
"Toggle word wrap",
},
n = {
function()
utils.toggle("relativenumber", true)
utils.toggle("number")
end,
"Toggle line numbers",
},
d = {
function()
utils.toggle_diagnostics()
end,
"Toggle Diagnostics",
},
c = {
function()
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
utils.toggle("conceallevel", false, { 0, conceallevel })
end,
"Toggle conceal",
},
h = {
function()
local sidescrolloff = vim.o.sidescrolloff > 0 and vim.o.sidescrolloff or 8
utils.toggle("sidescrolloff", false, { 0, sidescrolloff })
end,
"Toggle side scroll off",
},
},
g = {
name = "+git",
g = {
function()
utils.float_term({ "lazygit" })
end,
"Lazygit (cwd)",
},
G = {
function()
utils.float_term({ "lazygit" }, { cwd = utils.get_root() })
end,
"Lazygit (root dir)",
},
},
z = {
name = "+zk",
I = { "<cmd>ZkIndex<cr>", "Index Notebook" },
n = {
"+new",
n = { "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", "New Note (zk dir)" },
N = {
"<cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<cr>",
"New Note (cwd)",
},
t = {
"<cmd>ZkNewFromTitleSelection { title = vim.fn.input('Title: ') }<cr>",
"New, Title from selection (zk dir)",
},
T = {
"<cmd>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') title = vim.fn.input('Title: ') }<cr>",
"New, Title from selection (cwd)",
},
c = {
"<cmd>ZkNewFromContentSelection { title = vim.fn.input('Title: ') }<cr>",
"New, Content from selection (zk dir)",
},
C = {
"<cmd>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h') title = vim.fn.input('Title: ') }<cr>",
"New, Content from selection (cwd)",
},
},
c = { "<cmd>ZkCd<cr>", "cd 'root'" },
s = { "<cmd>ZkNotes<cr>", "List Notes" },
b = { "<cmd>ZkBacklinks<cr>", "Backlinks" },
l = { "<cmd>ZkLinks<cr>", "Links" },
j = {
"<cmd>ZkNew { dir = 'journal', date = 'today', title = vim.fn.input('Title: ') }<cr>",
"New Journal",
},
i = {
{ "<cmd>ZkInsertLink<cr>", "Insert Link" },
},
},
-- TODO: Add dap back into the project, bashbunni's dotfiles are a good resource.
-- 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,
},
}