local api = vim.api local wk = require('which-key') -------------------- -- Basic bindings -- -------------------- -- No one likes Esc api.nvim_set_keymap('i', 'jk', [[]], {noremap = true, silent = true}) -- Escape to normal mode in terminal buffer api.nvim_set_keymap('t', '', '', {noremap = true, silent = true}) -- Continuous indent api.nvim_set_keymap('v', '<', '', '>gv', {noremap = true, silent = true}) -- Normal mode wk.register({ -- Better Y Y = {'y$', 'Yank to eol'}, -- Copy the whole buffer [''] = {'%y+', 'Copy whole buffer'}, -- 'Legacy' save buffer -- [''] = {':w', 'Write buffer'}, -- Close buffer [''] = {':bd!', 'Close buffer'}, -- Remove trailing whitespace [''] = {':%s/\\s\\+$//e', 'Remove trailing'}, -- Resize buffer [''] = {':resize -2', 'Resize vertical -2'}, [''] = {':resize +2', 'Resize vertical +2'}, [''] = {':vertical resize -2', 'Resize horizontal -2'}, [''] = {':vertical resize +2', 'Resize horizontal +2'}, -- Switch between tabs and spaces [''] = { function() if vim.o.expandtab == true then vim.cmd('set noexpandtab nosmarttab softtabstop& shiftwidth&') vim.cmd('echomsg "Switched to indent with tabs"') else vim.opt.expandtab = true vim.opt.smarttab = true vim.opt.softtabstop = 4 vim.opt.shiftwidth = 4 vim.cmd('echomsg "Switched to indent with 4 spaces"') end end, 'Switch indent style' }, -- Naming common keys ['['] = {name = 'Block motions (previous)'}, [']'] = {name = 'Block motions (next)'}, g = {name = 'Goto motions'}, z = {name = 'Misc utils'} }) ------------- -- Plugins -- ------------- -- Normal mode wk.register({ -- Don't need to show bufferline numbers ['1'] = 'which_key_ignore', ['2'] = 'which_key_ignore', ['3'] = 'which_key_ignore', ['4'] = 'which_key_ignore', ['5'] = 'which_key_ignore', ['6'] = 'which_key_ignore', ['7'] = 'which_key_ignore', ['8'] = 'which_key_ignore', ['9'] = 'which_key_ignore', -- Move between tabs [''] = {'BufferLineCycleNext', 'Next buffer'}, [''] = {'BufferLineCyclePrev', 'Previous buffer'}, -- NvimTree [''] = {':NvimTreeToggle', 'NvimTree'}, -- ToggleTerm [''] = 'Toggle terminal', }) -- With leader key (normal mode) wk.register({ -- GitSigns g = { name = 'Git', b = 'Blame current line', i = 'Preview hunk', n = 'Next hunk', p = 'Previous hunk', r = 'Reset hunk', R = 'Reset all hunks in buffer', s = 'Stage hunk', u = 'Undo hunk' }, -- Telescope f = { name = 'Telescope' }, b = { name = 'Buffer', n = {':DashboardNewFile', 'New file'} } }, {prefix = ''}) -- With leader key (visual mode) wk.register({ -- GitSigns g = { name = 'Git', r = 'Reset hunk', s = 'Stage hunk' } }, {mode = 'v', prefix = ''})