feat: Add some more which-key specs for default maps

This commit is contained in:
punkfairie 2024-12-08 14:57:36 -08:00
parent 356686202d
commit 5d501b2db4
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696
3 changed files with 213 additions and 67 deletions

View file

@ -1,13 +1,22 @@
---@type {[string]:"azure" | "blue" | "cyan" | "green" | "grey" | "orange" | "purple" | "red" | "yellow"} ---@type {[string]:"azure" | "blue" | "cyan" | "green" | "grey" | "orange" | "purple" | "red" | "yellow"}
return { return {
buffers = 'cyan', buffers = 'cyan',
change = 'cyan',
delete = 'red',
diagnostics = 'green', diagnostics = 'green',
explorer = 'yellow',
fold = 'purple',
format = 'purple',
git = 'orange',
go_to = 'cyan',
notifications = 'orange',
replace = 'blue',
search = 'green',
sessions = 'azure',
spell = 'red',
surround = 'purple', surround = 'purple',
ui = 'green', ui = 'green',
visual = 'purple',
window = 'blue', window = 'blue',
search = 'green', yank = 'yellow',
git = 'orange',
notifications = 'orange',
sessions = 'azure',
explorer = 'yellow',
} }

View file

@ -1,15 +1,25 @@
return { return {
bottom = '',
center = '󰘢',
change = '',
char = '󰾹',
comment = '',
dashboard = {
quit = '',
mru = '',
project = '',
},
delete = '󰆴',
diagnostics = { diagnostics = {
Error = '', Error = '',
Warn = '', Warn = '',
Hint = '', Hint = '',
Info = '', Info = '',
}, },
dashboard = { explorer = '󰙅',
quit = '', first = '󰘀',
mru = '', fold = '',
project = '', format = '󰉼',
},
git = { git = {
added = '', added = '',
modified = '', modified = '',
@ -18,11 +28,29 @@ return {
staged = '󰱒', staged = '󰱒',
diff = '󰫙', diff = '󰫙',
}, },
left = '', go_to = '',
prev = '', indent = {
right = '', left = '󰉵',
next = '', decrease = '󰉵',
first = '󰘀', right = '󰉶',
increase = '󰉶',
},
last = '󰘁', last = '󰘁',
lazygit = '',
left = '',
next = '',
notifications = '󰈸',
prev = '',
registers = '󰅍',
replace = '',
right = '',
sessions = '',
spell = '',
search = '',
top = '',
ui = '󰙵',
undo = '', undo = '',
visual = '',
word = '',
yank = '',
} }

View file

@ -21,41 +21,20 @@ return {
require('lz.n').trigger_load('mini.icons') require('lz.n').trigger_load('mini.icons')
end, end,
after = function() after = function()
local icons = require('icons') local i = require('icons')
local colors = require('colors') local c = require('colors')
require('which-key').setup({ require('which-key').setup({
preset = 'modern', preset = 'modern',
spec = { spec = {
{ {
mode = { 'n', 'v' }, mode = { 'n', 'v' },
{
'<LEADER>',
group = 'leader',
icon = { icon = '', color = 'green' },
},
{ '<LEADER><TAB>', group = 'tabs' }, { '<LEADER><TAB>', group = 'tabs' },
{ '<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 = '󰙵 ', color = colors.ui },
},
{
'<LEADER>x',
group = 'diagnostics/quickfix',
icon = { icon = '󱖫 ', color = colors.diagnostics },
},
{ '[', group = 'previous' },
{ ']', group = 'next' },
{ 'g', group = 'goto' },
{
'gs',
group = 'surround',
icon = { icon = '󰅲', color = colors.surround },
},
{ 'z', group = 'fold' },
{ {
'<LEADER>b', '<LEADER>b',
group = 'buffer', group = 'buffer',
@ -63,6 +42,15 @@ return {
return require('which-key.extras').expand.buf() return require('which-key.extras').expand.buf()
end, 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', '<LEADER>w',
group = 'windows', group = 'windows',
@ -70,10 +58,114 @@ return {
return require('which-key.extras').expand.win() return require('which-key.extras').expand.win()
end, end,
}, },
{ 'gx', desc = 'open with system app' }, {
{ '<LEADER>ur', icon = { icon = '', color = colors.ui } }, '<LEADER>x',
{ '<LEADER>|', icon = { icon = '' } }, group = 'diagnostics/quickfix',
{ '<LEADER>-', icon = { icon = '' } }, 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' }, mode = { 'n', 'i' },
@ -88,42 +180,59 @@ return {
hidden = true, hidden = true,
{ 'j' }, { 'j' },
{ 'k' }, { 'k' },
}, { 'h' },
{ { 'l' },
mode = { 'v' }, { '<PLUG>' },
{ '<', icon = { icon = '󰉵' } },
{ '>', icon = { icon = '󰉶' } },
}, },
}, },
icons = { icons = {
rules = { rules = {
{ pattern = 'explorer', icon = '󰙅', color = colors.explorer }, { pattern = 'fold', icon = i.fold, color = c.fold },
{ pattern = 'lazygit', icon = '' },
{ pattern = 'comment', icon = '' }, { pattern = 'buffer', color = c.buffer },
{ pattern = 'buffer', color = colors.buffer }, { pattern = 'change', icon = i.change, color = c.change },
{ { pattern = 'comment', icon = i.comment },
pattern = 'notification', { pattern = 'delete', icon = i.delete, color = c.delete },
icon = '󰈸',
color = colors.notifications,
},
{ pattern = 'message', icon = '󰈸', color = colors.notifications },
{ pattern = 'session', icon = '', color = colors.sessions },
{ pattern = 'hunk', color = colors.git },
{ {
pattern = 'diagnostic', pattern = 'diagnostic',
icon = icons.diagnostics.Info, icon = i.diagnostics.Info,
hl = 'DiagnosticInfo', hl = 'DiagnosticInfo',
}, },
{ {
pattern = 'error', pattern = 'error',
icon = icons.diagnostics.Error, icon = i.diagnostics.Error,
hl = 'DiagnosticError', 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', pattern = ' warning',
icon = icons.diagnostics.Warning, icon = i.diagnostics.Warning,
hl = 'DiagnosticWarn', hl = 'DiagnosticWarn',
}, },
{ pattern = 'yank', icon = i.yank, color = c.yank },
}, },
}, },
}) })