Skip to content

Commit b23e35f

Browse files
iton0alextilot
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 8d658e3 commit b23e35f

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
@@ -290,57 +290,55 @@ require('lazy').setup({
290290
{ -- Useful plugin to show you pending keybinds.
291291
'folke/which-key.nvim',
292292
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
293-
config = function() -- This is the function that runs, AFTER loading
294-
require('which-key').setup {
295-
icons = {
296-
-- set icon mappings to true if you have a Nerd Font
297-
mappings = vim.g.have_nerd_font,
298-
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
299-
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
300-
keys = vim.g.have_nerd_font and {} or {
301-
Up = '<Up> ',
302-
Down = '<Down> ',
303-
Left = '<Left> ',
304-
Right = '<Right> ',
305-
C = '<C-…> ',
306-
M = '<M-…> ',
307-
D = '<D-…> ',
308-
S = '<S-…> ',
309-
CR = '<CR> ',
310-
Esc = '<Esc> ',
311-
ScrollWheelDown = '<ScrollWheelDown> ',
312-
ScrollWheelUp = '<ScrollWheelUp> ',
313-
NL = '<NL> ',
314-
BS = '<BS> ',
315-
Space = '<Space> ',
316-
Tab = '<Tab> ',
317-
F1 = '<F1>',
318-
F2 = '<F2>',
319-
F3 = '<F3>',
320-
F4 = '<F4>',
321-
F5 = '<F5>',
322-
F6 = '<F6>',
323-
F7 = '<F7>',
324-
F8 = '<F8>',
325-
F9 = '<F9>',
326-
F10 = '<F10>',
327-
F11 = '<F11>',
328-
F12 = '<F12>',
329-
},
293+
opts = {
294+
icons = {
295+
-- set icon mappings to true if you have a Nerd Font
296+
mappings = vim.g.have_nerd_font,
297+
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
298+
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
299+
keys = vim.g.have_nerd_font and {} or {
300+
Up = '<Up> ',
301+
Down = '<Down> ',
302+
Left = '<Left> ',
303+
Right = '<Right> ',
304+
C = '<C-…> ',
305+
M = '<M-…> ',
306+
D = '<D-…> ',
307+
S = '<S-…> ',
308+
CR = '<CR> ',
309+
Esc = '<Esc> ',
310+
ScrollWheelDown = '<ScrollWheelDown> ',
311+
ScrollWheelUp = '<ScrollWheelUp> ',
312+
NL = '<NL> ',
313+
BS = '<BS> ',
314+
Space = '<Space> ',
315+
Tab = '<Tab> ',
316+
F1 = '<F1>',
317+
F2 = '<F2>',
318+
F3 = '<F3>',
319+
F4 = '<F4>',
320+
F5 = '<F5>',
321+
F6 = '<F6>',
322+
F7 = '<F7>',
323+
F8 = '<F8>',
324+
F9 = '<F9>',
325+
F10 = '<F10>',
326+
F11 = '<F11>',
327+
F12 = '<F12>',
330328
},
331-
}
332329

333-
-- Document existing key chains
334-
require('which-key').add {
335-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
336-
{ '<leader>d', group = '[D]ocument' },
337-
{ '<leader>r', group = '[R]ename' },
338-
{ '<leader>s', group = '[S]earch' },
339-
{ '<leader>w', group = '[W]orkspace' },
340-
{ '<leader>t', group = '[T]oggle' },
341-
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
342-
}
343-
end,
330+
-- Document existing key chains
331+
spec = {
332+
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
333+
{ '<leader>d', group = '[D]ocument' },
334+
{ '<leader>r', group = '[R]ename' },
335+
{ '<leader>s', group = '[S]earch' },
336+
{ '<leader>w', group = '[W]orkspace' },
337+
{ '<leader>t', group = '[T]oggle' },
338+
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
339+
},
340+
},
341+
},
344342
},
345343

346344
-- NOTE: Plugins can specify dependencies.

0 commit comments

Comments
 (0)