Skip to content

Commit 6734b9a

Browse files
iton0flatplate
authored andcommitted
cleanup: refactor which-key configuration for cleaner setup (nvim-lua#1102)
- Moved `which-key` configuration from inline `config` to `opts` for better organization. - Updated the key mappings setup to use `spec` for defining existing key chains. - Removed deprecated or unnecessary comments and code. This change aligns with updated `which-key` configuration practices, improving readability and maintainability as recommended by @VlaDexa in nvim-lua#1068.
1 parent bf99095 commit 6734b9a

File tree

1 file changed

+47
-49
lines changed

1 file changed

+47
-49
lines changed

init.lua

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -845,57 +845,55 @@ require('lazy').setup({
845845
{ -- Useful plugin to show you pending keybinds.
846846
'folke/which-key.nvim',
847847
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
848-
config = function() -- This is the function that runs, AFTER loading
849-
require('which-key').setup {
850-
icons = {
851-
-- set icon mappings to true if you have a Nerd Font
852-
mappings = vim.g.have_nerd_font,
853-
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
854-
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
855-
keys = vim.g.have_nerd_font and {} or {
856-
Up = '<Up> ',
857-
Down = '<Down> ',
858-
Left = '<Left> ',
859-
Right = '<Right> ',
860-
C = '<C-…> ',
861-
M = '<M-…> ',
862-
D = '<D-…> ',
863-
S = '<S-…> ',
864-
CR = '<CR> ',
865-
Esc = '<Esc> ',
866-
ScrollWheelDown = '<ScrollWheelDown> ',
867-
ScrollWheelUp = '<ScrollWheelUp> ',
868-
NL = '<NL> ',
869-
BS = '<BS> ',
870-
Space = '<Space> ',
871-
Tab = '<Tab> ',
872-
F1 = '<F1>',
873-
F2 = '<F2>',
874-
F3 = '<F3>',
875-
F4 = '<F4>',
876-
F5 = '<F5>',
877-
F6 = '<F6>',
878-
F7 = '<F7>',
879-
F8 = '<F8>',
880-
F9 = '<F9>',
881-
F10 = '<F10>',
882-
F11 = '<F11>',
883-
F12 = '<F12>',
884-
},
848+
opts = {
849+
icons = {
850+
-- set icon mappings to true if you have a Nerd Font
851+
mappings = vim.g.have_nerd_font,
852+
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
853+
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
854+
keys = vim.g.have_nerd_font and {} or {
855+
Up = '<Up> ',
856+
Down = '<Down> ',
857+
Left = '<Left> ',
858+
Right = '<Right> ',
859+
C = '<C-…> ',
860+
M = '<M-…> ',
861+
D = '<D-…> ',
862+
S = '<S-…> ',
863+
CR = '<CR> ',
864+
Esc = '<Esc> ',
865+
ScrollWheelDown = '<ScrollWheelDown> ',
866+
ScrollWheelUp = '<ScrollWheelUp> ',
867+
NL = '<NL> ',
868+
BS = '<BS> ',
869+
Space = '<Space> ',
870+
Tab = '<Tab> ',
871+
F1 = '<F1>',
872+
F2 = '<F2>',
873+
F3 = '<F3>',
874+
F4 = '<F4>',
875+
F5 = '<F5>',
876+
F6 = '<F6>',
877+
F7 = '<F7>',
878+
F8 = '<F8>',
879+
F9 = '<F9>',
880+
F10 = '<F10>',
881+
F11 = '<F11>',
882+
F12 = '<F12>',
885883
},
886-
}
887884

888-
-- Document existing key chains
889-
require('which-key').add {
890-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
891-
{ '<leader>d', group = '[D]ocument' },
892-
{ '<leader>r', group = '[R]ename' },
893-
{ '<leader>s', group = '[S]earch' },
894-
{ '<leader>w', group = '[W]orkspace' },
895-
{ '<leader>t', group = '[T]oggle' },
896-
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
897-
}
898-
end,
885+
-- Document existing key chains
886+
spec = {
887+
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
888+
{ '<leader>d', group = '[D]ocument' },
889+
{ '<leader>r', group = '[R]ename' },
890+
{ '<leader>s', group = '[S]earch' },
891+
{ '<leader>w', group = '[W]orkspace' },
892+
{ '<leader>t', group = '[T]oggle' },
893+
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
894+
},
895+
},
896+
},
899897
},
900898

901899
-- NOTE: Plugins can specify dependencies.

0 commit comments

Comments
 (0)