This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/neovim/lua/keymap.lua

80 lines
2.5 KiB
Lua
Raw Normal View History

2022-04-15 12:52:46 -05:00
for _, keys in ipairs { 'jj', 'jJ', 'Jj', 'JJ', 'jk', 'jK', 'Jk', 'JK' } do vim.api.nvim_set_keymap('i', keys, '<Esc>', {}) end
2021-06-13 11:02:27 -05:00
local m = {
2022-04-15 12:52:46 -05:00
s = { silent = true },
n = { noremap = true },
sn = { silent = true, noremap = true },
2021-06-13 11:02:27 -05:00
}
local keymap = {
n = {
2022-04-15 12:52:46 -05:00
['<leader>/'] = { ':let @/ = ""<cr>:<BACKSPACE>', m.s },
2022-03-09 11:50:01 -06:00
2022-04-15 12:52:46 -05:00
['<leader>r'] = { ':luafile ' .. vim.g.vimdir .. '/init.lua<cr>:echo \'Reloaded init.lua\'<cr>', m.s },
['<leader>gv'] = { ':e ' .. vim.g.vimdir .. '/init.lua<cr>', m.s },
2022-03-09 11:50:01 -06:00
2022-04-15 12:52:46 -05:00
['<leader>w'] = { ':bd<cr>', m.s },
['<leader>h'] = { ':b#<cr>', m.s },
['<leader>k'] = { ':bnext<cr>', m.s },
['<leader>j'] = { ':bprevious<cr>', m.s },
2022-03-09 11:50:01 -06:00
2021-06-13 11:02:27 -05:00
['<c-q>'] = ':qa<cr>',
2022-03-09 11:50:01 -06:00
2021-06-13 11:02:27 -05:00
['<c-p>'] = '<cmd>Telescope git_files<cr>',
['<c-g>'] = '<cmd>Telescope live_grep<cr>',
['<c-b>'] = '<cmd>Telescope buffers<cr>',
['<leader>t'] = '<cmd>Telescope help_tags<cr>',
2022-03-09 11:50:01 -06:00
2021-06-13 11:02:27 -05:00
['<c-h>'] = ':TmuxNavigateLeft<cr>',
['<c-j>'] = ':TmuxNavigateDown<cr>',
['<c-k>'] = ':TmuxNavigateUp<cr>',
['<c-l>'] = ':TmuxNavigateRight<cr>',
2022-03-09 11:50:01 -06:00
2021-06-13 11:02:27 -05:00
['<expr> n'] = "'Nn'[v:searchforward]",
['<expr> N'] = "'nN'[v:searchforward]",
2021-11-11 11:44:26 -06:00
['<c-m>'] = ':lua SynGroup()<cr>',
2022-03-09 13:37:25 -06:00
['<leader>s'] = "<cmd>SessionToggle<cr><cmd>echo 'Persisting Session: ' .. g:persisting .. ' (' .. getcwd() .. ')'<cr>",
['<leader>S'] = "<cmd>SessionSave<cr><cmd>echo 'Saved Session: ' .. getcwd()<cr>",
['<leader>l'] = "<cmd>SessionLoad<cr><cmd>echo 'Loaded Session: ' .. getcwd()<cr>",
['<leader>L'] = "<cmd>SessionLoadLast<cr><cmd>echo 'Loaded Last Session: ' .. getcwd()<cr>",
['<leader>d'] = "<cmd>SessionDelete<cr><cmd>echo 'Deleted Session for cwd: ' .. getcwd()<cr>",
2021-06-13 11:02:27 -05:00
},
2022-03-09 11:50:01 -06:00
-- terminal bindings
2021-06-13 11:02:27 -05:00
t = {},
2022-03-09 11:50:01 -06:00
2021-06-13 11:02:27 -05:00
[''] = {
2022-04-15 12:52:46 -05:00
['<space>'] = { '<nop>', m.sn },
2022-03-09 11:50:01 -06:00
-- remove trailing whitespace
2021-06-13 11:02:27 -05:00
['<f3>'] = 'mw:%s/\\s\\+$//<cr>:let @/ = ""<cr>\'w',
2022-03-09 11:50:01 -06:00
['<leader>gs'] = ':setlocal spell!<cr>',
2022-04-15 12:52:46 -05:00
[',w'] = { '<Plug>CamelCaseMotion_w', m.s },
[',b'] = { '<Plug>CamelCaseMotion_b', m.s },
[',e'] = { '<Plug>CamelCaseMotion_e', m.s },
[',ge'] = { '<Plug>CamelCaseMotion_ge', m.s },
2021-06-13 11:02:27 -05:00
},
o = {
2022-04-15 12:52:46 -05:00
['ib'] = { '<Plug>CamelCaseMotion_ib', m.s },
['ie'] = { '<Plug>CamelCaseMotion_ie', m.s },
2021-06-13 11:02:27 -05:00
},
x = {
['<'] = '<gv',
['>'] = '>gv',
2022-04-15 12:52:46 -05:00
['ib'] = { '<Plug>CamelCaseMotion_ib', m.s },
['ie'] = { '<Plug>CamelCaseMotion_ie', m.s },
2021-06-13 11:02:27 -05:00
},
i = {
['<c-q>'] = '<esc><c-q>',
},
}
2022-04-15 12:52:46 -05:00
for mode, mappings in pairs(keymap) do
for key, bind in pairs(mappings) do
2021-06-13 11:02:27 -05:00
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