From 9b0117b2e31c9118eceb1ed5f6b0ab1f8df6a8d5 Mon Sep 17 00:00:00 2001
From: punkfairie <marley@punkfairie.net>
Date: Sun, 8 Dec 2024 14:57:36 -0800
Subject: [PATCH] feat: Add some more which-key specs for default maps

---
 nvim/lua/colors.lua                        |  19 +-
 nvim/lua/icons.lua                         |  48 ++++-
 nvim/lua/plugins/editor/which-key-nvim.lua | 213 ++++++++++++++++-----
 3 files changed, 213 insertions(+), 67 deletions(-)

diff --git a/nvim/lua/colors.lua b/nvim/lua/colors.lua
index 5276978..e51cc55 100644
--- a/nvim/lua/colors.lua
+++ b/nvim/lua/colors.lua
@@ -1,13 +1,22 @@
 ---@type {[string]:"azure" | "blue" | "cyan" | "green" | "grey" | "orange" | "purple" | "red" | "yellow"}
 return {
   buffers = 'cyan',
+  change = 'cyan',
+  delete = 'red',
   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',
   ui = 'green',
+  visual = 'purple',
   window = 'blue',
-  search = 'green',
-  git = 'orange',
-  notifications = 'orange',
-  sessions = 'azure',
-  explorer = 'yellow',
+  yank = 'yellow',
 }
diff --git a/nvim/lua/icons.lua b/nvim/lua/icons.lua
index 0983c85..019c312 100644
--- a/nvim/lua/icons.lua
+++ b/nvim/lua/icons.lua
@@ -1,15 +1,25 @@
 return {
+  bottom = '',
+  center = '󰘢',
+  change = '',
+  char = '󰾹',
+  comment = '',
+  dashboard = {
+    quit = '',
+    mru = '',
+    project = '',
+  },
+  delete = '󰆴',
   diagnostics = {
     Error = ' ',
     Warn = ' ',
     Hint = ' ',
     Info = ' ',
   },
-  dashboard = {
-    quit = '',
-    mru = '',
-    project = '',
-  },
+  explorer = '󰙅',
+  first = '󰘀',
+  fold = '',
+  format = '󰉼',
   git = {
     added = ' ',
     modified = ' ',
@@ -18,11 +28,29 @@ return {
     staged = '󰱒',
     diff = '󰫙',
   },
-  left = '',
-  prev = '',
-  right = '',
-  next = '',
-  first = '󰘀',
+  go_to = '',
+  indent = {
+    left = '󰉵',
+    decrease = '󰉵',
+    right = '󰉶',
+    increase = '󰉶',
+  },
   last = '󰘁',
+  lazygit = '',
+  left = '',
+  next = '',
+  notifications = '󰈸',
+  prev = '',
+  registers = '󰅍',
+  replace = '',
+  right = '',
+  sessions = '',
+  spell = '',
+  search = '',
+  top = '',
+  ui = '󰙵',
   undo = '',
+  visual = '',
+  word = '',
+  yank = '',
 }
diff --git a/nvim/lua/plugins/editor/which-key-nvim.lua b/nvim/lua/plugins/editor/which-key-nvim.lua
index e4614e6..17cd877 100644
--- a/nvim/lua/plugins/editor/which-key-nvim.lua
+++ b/nvim/lua/plugins/editor/which-key-nvim.lua
@@ -21,41 +21,20 @@ return {
     require('lz.n').trigger_load('mini.icons')
   end,
   after = function()
-    local icons = require('icons')
-    local colors = require('colors')
+    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>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',
@@ -63,6 +42,15 @@ return {
               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',
@@ -70,10 +58,114 @@ return {
               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 = '' } },
+          {
+            '<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' },
@@ -88,42 +180,59 @@ return {
           hidden = true,
           { 'j' },
           { 'k' },
-        },
-        {
-          mode = { 'v' },
-          { '<', icon = { icon = '󰉵' } },
-          { '>', icon = { icon = '󰉶' } },
+          { 'h' },
+          { 'l' },
+          { '<PLUG>' },
         },
       },
       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 = '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 = icons.diagnostics.Info,
+            icon = i.diagnostics.Info,
             hl = 'DiagnosticInfo',
           },
           {
             pattern = 'error',
-            icon = icons.diagnostics.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 = icons.diagnostics.Warning,
+            icon = i.diagnostics.Warning,
             hl = 'DiagnosticWarn',
           },
+          { pattern = 'yank', icon = i.yank, color = c.yank },
         },
       },
     })