Skip to content

Commit 24d368f

Browse files
authored
cleanup: refactor which-key configuration for cleaner setup (#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 #1068.
1 parent c76c323 commit 24d368f

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
@@ -274,57 +274,55 @@ require('lazy').setup({
274274
{ -- Useful plugin to show you pending keybinds.
275275
'folke/which-key.nvim',
276276
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
277-
config = function() -- This is the function that runs, AFTER loading
278-
require('which-key').setup {
279-
icons = {
280-
-- set icon mappings to true if you have a Nerd Font
281-
mappings = vim.g.have_nerd_font,
282-
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
283-
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
284-
keys = vim.g.have_nerd_font and {} or {
285-
Up = '<Up> ',
286-
Down = '<Down> ',
287-
Left = '<Left> ',
288-
Right = '<Right> ',
289-
C = '<C-…> ',
290-
M = '<M-…> ',
291-
D = '<D-…> ',
292-
S = '<S-…> ',
293-
CR = '<CR> ',
294-
Esc = '<Esc> ',
295-
ScrollWheelDown = '<ScrollWheelDown> ',
296-
ScrollWheelUp = '<ScrollWheelUp> ',
297-
NL = '<NL> ',
298-
BS = '<BS> ',
299-
Space = '<Space> ',
300-
Tab = '<Tab> ',
301-
F1 = '<F1>',
302-
F2 = '<F2>',
303-
F3 = '<F3>',
304-
F4 = '<F4>',
305-
F5 = '<F5>',
306-
F6 = '<F6>',
307-
F7 = '<F7>',
308-
F8 = '<F8>',
309-
F9 = '<F9>',
310-
F10 = '<F10>',
311-
F11 = '<F11>',
312-
F12 = '<F12>',
313-
},
277+
opts = {
278+
icons = {
279+
-- set icon mappings to true if you have a Nerd Font
280+
mappings = vim.g.have_nerd_font,
281+
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
282+
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
283+
keys = vim.g.have_nerd_font and {} or {
284+
Up = '<Up> ',
285+
Down = '<Down> ',
286+
Left = '<Left> ',
287+
Right = '<Right> ',
288+
C = '<C-…> ',
289+
M = '<M-…> ',
290+
D = '<D-…> ',
291+
S = '<S-…> ',
292+
CR = '<CR> ',
293+
Esc = '<Esc> ',
294+
ScrollWheelDown = '<ScrollWheelDown> ',
295+
ScrollWheelUp = '<ScrollWheelUp> ',
296+
NL = '<NL> ',
297+
BS = '<BS> ',
298+
Space = '<Space> ',
299+
Tab = '<Tab> ',
300+
F1 = '<F1>',
301+
F2 = '<F2>',
302+
F3 = '<F3>',
303+
F4 = '<F4>',
304+
F5 = '<F5>',
305+
F6 = '<F6>',
306+
F7 = '<F7>',
307+
F8 = '<F8>',
308+
F9 = '<F9>',
309+
F10 = '<F10>',
310+
F11 = '<F11>',
311+
F12 = '<F12>',
314312
},
315-
}
316313

317-
-- Document existing key chains
318-
require('which-key').add {
319-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
320-
{ '<leader>d', group = '[D]ocument' },
321-
{ '<leader>r', group = '[R]ename' },
322-
{ '<leader>s', group = '[S]earch' },
323-
{ '<leader>w', group = '[W]orkspace' },
324-
{ '<leader>t', group = '[T]oggle' },
325-
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
326-
}
327-
end,
314+
-- Document existing key chains
315+
spec = {
316+
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
317+
{ '<leader>d', group = '[D]ocument' },
318+
{ '<leader>r', group = '[R]ename' },
319+
{ '<leader>s', group = '[S]earch' },
320+
{ '<leader>w', group = '[W]orkspace' },
321+
{ '<leader>t', group = '[T]oggle' },
322+
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
323+
},
324+
},
325+
},
328326
},
329327

330328
-- NOTE: Plugins can specify dependencies.

0 commit comments

Comments
 (0)