marleyvim/nvim/lua/plugins/editor/which-key-nvim.lua

240 lines
8.8 KiB
Lua

return {
'which-key.nvim',
event = 'DeferredUIEnter',
keys = {
{
'<LEADER>?',
function()
require('which-key').show({ global = false })
end,
desc = 'buffer keymaps (which key)',
},
{
'<C-w><SPACE>',
function()
require('which-key').show({ keys = '<C-w>', loop = true })
end,
desc = 'window hydra mode (which key)',
},
},
before = function()
require('lz.n').trigger_load('mini.icons')
end,
after = function()
local i = require('icons')
local c = require('colors')
require('which-key').setup({
preset = 'modern',
spec = {
{
mode = { 'n', 'v' },
{
'<LEADER>',
group = 'leader',
icon = { icon = '', color = 'green' },
},
{ '<LEADER><TAB>', group = 'tabs' },
{
'<LEADER>b',
group = 'buffer',
expand = function()
return require('which-key.extras').expand.buf()
end,
},
{ '<LEADER>c', group = 'code' },
{ '<LEADER>f', group = 'file/find' },
{ '<LEADER>g', group = 'git' },
{ '<LEADER>gh', group = 'hunks' },
{ '<LEADER>n', group = 'notifications' },
{ '<LEADER>q', group = 'quit/session' },
{ '<LEADER>s', group = 'search' },
{ '<LEADER>u', group = 'ui', icon = { icon = i.ui, color = c.ui } },
{ '<LEADER>ur', icon = { icon = '', color = c.ui } },
{
'<LEADER>w',
group = 'windows',
expand = function()
return require('which-key.extras').expand.win()
end,
},
{
'<LEADER>x',
group = 'diagnostics/quickfix',
icon = { icon = '󱖫 ', color = c.diagnostics },
},
{ '<LEADER>|', icon = '' },
{ '<LEADER>-', icon = '' },
{ '0', desc = 'start of line', icon = i.first },
{ 'b', desc = 'previous word', icon = i.word },
{ 'B', desc = 'previous WORD', icon = i.word },
{ 'c', desc = 'change' },
{ 'd', desc = 'delete' },
{ 'e', desc = 'next end of word', icon = i.word },
{ 'E', desc = 'next end of WORD', icon = i.word },
{ 'f', desc = 'find next char' },
{ 'F', desc = 'find previous char' },
{ 'g', group = 'goto', icon = { icon = i.go_to, color = c.go_to } },
{ 'gc', group = 'toggle comment' },
{ 'ge', desc = 'previous end of word', icon = i.word },
{ 'gf', desc = 'file under cursor' },
{ 'gg', desc = 'first line', icon = i.first },
{ 'gi', desc = 'last insert' },
{ 'gn', desc = 'search forward & select' },
{ 'gN', desc = 'search backward & select' },
{ 'gO', desc = 'document symbols', icon = '󰊕' },
{ 'gt', desc = 'next tab page' },
{ 'gT', desc = 'previous tab page' },
{ 'gu', desc = 'make lowercase', icon = '󰬵' },
{ 'gU', desc = 'make uppercase', icon = '󰬶' },
{ 'gv', desc = 'last visual selection' },
{ 'w', desc = 'format' },
{
'gs',
group = 'surround',
icon = { icon = '󰅲', color = c.surround },
},
{ 'gx', desc = 'open with system app', icon = '󰏋' },
{ 'g%', desc = 'cycle backward through results' },
{ 'g~', desc = 'toggle case' },
{ 'G', desc = 'last line', icon = i.last },
{ 'M', desc = 'middle line of window', icon = i.center },
{ 'r', desc = 'replace' },
{ 't', desc = 'find before next char' },
{ 'T', desc = 'find before previous char' },
{ 'v', desc = 'visual' },
{ 'V', desc = 'visual line' },
{ 'w', desc = 'next word', icon = i.word },
{ 'W', desc = 'next WORD', icon = i.word },
{ 'y', desc = 'yank' },
{ 'Y', desc = 'yank to end of line' },
{ 'z', group = 'fold/scroll/spell', icon = '' },
{ 'za', desc = 'toggle fold under cursor' },
{ 'zA', desc = 'toggle all folds under cursor' },
{ 'zb', desc = 'bottom this line', icon = i.bottom },
{ 'zc', desc = 'close fold under cursor' },
{ 'zC', desc = 'close all fold under cursor' },
{ 'zd', desc = 'delete fold under cursor' },
{ 'zD', desc = 'delete all folds under cursor' },
{ 'ze', desc = 'right this line', icon = i.right },
{ 'zE', desc = 'delete all folds in file' },
{ 'zf', desc = 'create fold' },
{ 'zg', desc = 'mark word as correctly spelled' },
{ 'zH', desc = 'half screen to the left', icon = i.left },
{ 'zi', desc = 'toggle folding' },
{ 'zL', desc = 'half screen to the right', icon = i.right },
{ 'zm', desc = 'fold more' },
{ 'zM', desc = 'close all folds' },
{ 'zo', desc = 'open fold under cursor' },
{ 'zO', desc = 'open all folds under cursor' },
{ 'zr', desc = 'fold less' },
{ 'zR', desc = 'open all folds' },
{ 'zs', desc = 'left this line', icon = i.left },
{ 'zt', desc = 'top this line', icon = i.top },
{ 'zv', desc = 'show cursor line' },
{ 'zw', desc = 'mark word as mispelled' },
{ 'zx', desc = 'update folds' },
{ 'zz', desc = 'center this line', icon = i.center },
{ 'z<CR>', desc = 'top this line', icon = i.top },
{ 'z=', group = 'spelling suggestions' },
{ '[', group = 'previous', icon = i.prev },
{ ']', group = 'next', icon = i.next },
{ '!', desc = 'run program', icon = '' },
{ '$', desc = 'end of line', icon = i.last },
{ '%', desc = 'matching (){}[]', icon = '󰅪' },
{ '&', desc = 'repeat last subsitute' },
{ ',', desc = 'repeat last char search (backwards)' },
{ '/', desc = 'search forward' },
{ ';', desc = 'repeat last char search' },
{ '<', desc = 'indent decrease', icon = i.indent.decrease },
{ '>', desc = 'indent increase', icon = i.indent.increase },
{ '?', desc = 'search backwards' },
{ '^', desc = 'first char of line', icon = i.first },
{ '_', desc = 'first char of line', icon = i.first },
{ '{', desc = 'previous empty line', icon = i.prev },
{ '}', desc = 'next empty line', icon = i.next },
{ '~', desc = 'toggle case' },
{
'<C-L>',
desc = 'clear & redraw',
icon = { icon = '', color = 'red' },
},
},
{
mode = { 'n', 'i' },
hidden = true,
{ '<DOWN>' },
{ '<UP>' },
{ '<LEFT>' },
{ '<RIGHT>' },
},
{
mode = { 'n', 'x' },
hidden = true,
{ 'j' },
{ 'k' },
{ 'h' },
{ 'l' },
{ '<PLUG>' },
},
},
icons = {
rules = {
{ pattern = 'fold', icon = i.fold, color = c.fold },
{ pattern = 'buffer', color = c.buffer },
{ pattern = 'change', icon = i.change, color = c.change },
{ pattern = 'comment', icon = i.comment },
{ pattern = 'delete', icon = i.delete, color = c.delete },
{
pattern = 'diagnostic',
icon = i.diagnostics.Info,
hl = 'DiagnosticInfo',
},
{
pattern = 'error',
icon = i.diagnostics.Error,
hl = 'DiagnosticError',
},
{
pattern = 'explorer',
icon = i.explorer,
color = c.explorer,
},
{ pattern = 'format', icon = i.format, color = c.format },
{ pattern = 'hunk', color = c.git },
{ pattern = 'lazygit', icon = i.git, color = c.git },
{
pattern = 'message',
icon = i.notifications,
color = c.notifications,
},
{
pattern = 'notification',
icon = i.notifications,
color = c.notifications,
},
{ pattern = 'registers', icon = i.registers, color = c.yank },
{ pattern = 'replace', icon = i.replace, colors = c.replace },
{ pattern = 'session', icon = i.sessions, color = c.sessions },
{ pattern = 'spell', icon = i.spell, color = c.spell },
{ pattern = 'subsitute', icon = i.search, color = c.search },
{ pattern = 'visual', icon = i.visual, color = c.visual },
{
pattern = ' warning',
icon = i.diagnostics.Warning,
hl = 'DiagnosticWarn',
},
{ pattern = 'yank', icon = i.yank, color = c.yank },
},
},
})
end,
}