for _, keys in ipairs { 'jj', 'jJ', 'Jj', 'JJ', 'jk', 'jK', 'Jk', 'JK' } do vim.api.nvim_set_keymap('i', keys, '', {}) end local m = { s = { silent = true }, n = { noremap = true }, sn = { silent = true, noremap = true }, } local keymap = { n = { ['/'] = { ':let @/ = "":', m.s }, ['r'] = { ':luafile ' .. vim.g.vimdir .. '/init.lua:echo \'Reloaded init.lua\'', m.s }, ['gv'] = { ':e ' .. vim.g.vimdir .. '/init.lua', m.s }, ['w'] = { ':bd', m.s }, ['h'] = { ':b#', m.s }, ['k'] = { ':bnext', m.s }, ['j'] = { ':bprevious', m.s }, [''] = ':qa', [''] = 'Telescope git_files', [''] = 'Telescope live_grep', [''] = 'Telescope buffers', ['t'] = 'Telescope help_tags', [''] = ':TmuxNavigateLeft', [''] = ':TmuxNavigateDown', [''] = ':TmuxNavigateUp', [''] = ':TmuxNavigateRight', [' n'] = "'Nn'[v:searchforward]", [' N'] = "'nN'[v:searchforward]", [''] = ':lua SynGroup()', ['s'] = "SessionToggleecho 'Persisting Session: ' .. g:persisting .. ' (' .. getcwd() .. ')'", ['S'] = "SessionSaveecho 'Saved Session: ' .. getcwd()", ['l'] = "SessionLoadecho 'Loaded Session: ' .. getcwd()", ['L'] = "SessionLoadLastecho 'Loaded Last Session: ' .. getcwd()", ['d'] = "SessionDeleteecho 'Deleted Session for cwd: ' .. getcwd()", }, -- terminal bindings t = {}, [''] = { [''] = { '', m.sn }, -- remove trailing whitespace [''] = 'mw:%s/\\s\\+$//:let @/ = ""\'w', ['gs'] = ':setlocal spell!', [',w'] = { 'CamelCaseMotion_w', m.s }, [',b'] = { 'CamelCaseMotion_b', m.s }, [',e'] = { 'CamelCaseMotion_e', m.s }, [',ge'] = { 'CamelCaseMotion_ge', m.s }, }, o = { ['ib'] = { 'CamelCaseMotion_ib', m.s }, ['ie'] = { 'CamelCaseMotion_ie', m.s }, }, x = { ['<'] = ''] = '>gv', ['ib'] = { 'CamelCaseMotion_ib', m.s }, ['ie'] = { 'CamelCaseMotion_ie', m.s }, }, i = { [''] = '', }, } for mode, mappings in pairs(keymap) do for key, bind in pairs(mappings) do if type(bind) == 'table' then vim.api.nvim_set_keymap(mode, key, bind[1], bind[2]) else vim.api.nvim_set_keymap(mode, key, bind, {}) end end end