marleyvim/nvim/lua/plugins/editor/which-key-nvim.lua
2024-12-04 21:35:35 -08:00

131 lines
3.7 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 icons = require('icons')
local colors = require('colors')
require('which-key').setup({
preset = 'modern',
spec = {
{
mode = { 'n', 'v' },
{ '<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',
group = 'buffer',
expand = function()
return require('which-key.extras').expand.buf()
end,
},
{
'<LEADER>w',
group = 'windows',
expand = function()
return require('which-key.extras').expand.win()
end,
},
{ 'gx', desc = 'open with system app' },
{ '<LEADER>ur', icon = { icon = '', color = colors.ui } },
{ '<LEADER>|', icon = { icon = '' } },
{ '<LEADER>-', icon = { icon = '' } },
},
{
mode = { 'n', 'i' },
hidden = true,
{ '<DOWN>' },
{ '<UP>' },
{ '<LEFT>' },
{ '<RIGHT>' },
},
{
mode = { 'n', 'x' },
hidden = true,
{ 'j' },
{ 'k' },
},
{
mode = { 'v' },
{ '<', icon = { icon = '󰉵' } },
{ '>', icon = { icon = '󰉶' } },
},
},
icons = {
rules = {
{ pattern = 'explorer', icon = '󰙅', color = colors.explorer },
{ pattern = 'lazygit', icon = '' },
{ pattern = 'comment', icon = '' },
{ pattern = 'buffer', color = colors.buffer },
{
pattern = 'notification',
icon = '󰈸',
color = colors.notifications,
},
{ pattern = 'message', icon = '󰈸', color = colors.notifications },
{ pattern = 'session', icon = '', color = colors.sessions },
{ pattern = 'hunk', color = colors.git },
{
pattern = 'diagnostic',
icon = icons.diagnostics.Info,
hl = 'DiagnosticInfo',
},
{
pattern = 'error',
icon = icons.diagnostics.Error,
hl = 'DiagnosticError',
},
{
pattern = ' warning',
icon = icons.diagnostics.Warning,
hl = 'DiagnosticWarn',
},
},
},
})
end,
}