2022-08-07 21:00:11 +08:00
|
|
|
local map = vim.api.nvim_set_keymap
|
|
|
|
|
2021-09-07 23:26:21 +08:00
|
|
|
-- generic mappings
|
2022-09-16 17:36:17 +08:00
|
|
|
map('v', '<', '<gv', { noremap = true })
|
|
|
|
map('v', '>', '>gv', { noremap = true })
|
|
|
|
map('n', 'Y', 'y$', { noremap = true })
|
|
|
|
map('n', 'n', 'nzzzv', { noremap = true })
|
|
|
|
map('n', 'N', 'Nzzzv', { noremap = true })
|
2022-08-07 21:00:11 +08:00
|
|
|
|
2021-09-07 23:26:21 +08:00
|
|
|
-- Shortcutting split navigation
|
2022-08-07 21:00:11 +08:00
|
|
|
map('', '<A-h>', '<C-w>h', {})
|
|
|
|
map('', '<A-j>', '<C-w>j', {})
|
|
|
|
map('', '<A-k>', '<C-w>k', {})
|
|
|
|
map('', '<A-l>', '<C-w>l', {})
|
|
|
|
map('', '<A-H>', '<C-w>H', {})
|
|
|
|
map('', '<A-J>', '<C-w>J', {})
|
|
|
|
map('', '<A-K>', '<C-w>K', {})
|
|
|
|
map('', '<A-L>', '<C-w>L', {})
|
2022-08-07 22:57:52 +08:00
|
|
|
map('', '<M-S-.>', '<C-w>>', {})
|
|
|
|
map('', '<M-S-,>', '<C-w><', {})
|
|
|
|
map('', '<M-S-=>', '<C-w>+', {})
|
|
|
|
map('', '<M-->', '<C-w>-', {})
|
2022-08-07 21:00:11 +08:00
|
|
|
map('', '<A-T>', '<C-w>T', {})
|
|
|
|
|
2021-09-07 23:26:21 +08:00
|
|
|
-- undo to the last , . or !
|
2022-09-16 17:36:17 +08:00
|
|
|
map('i', ',', ',<c-g>u', { noremap = true })
|
|
|
|
map('i', '.', '.<c-g>u', { noremap = true })
|
|
|
|
map('i', '!', '!<c-g>u', { noremap = true })
|
|
|
|
map('i', '?', '?<c-g>u', { noremap = true })
|
2021-09-15 15:18:15 +08:00
|
|
|
|
|
|
|
-- plugin mappings
|
2021-11-01 19:29:14 +08:00
|
|
|
-- gitsigns
|
2022-09-16 17:36:17 +08:00
|
|
|
map('', '<leader>gs', ':Gitsigns toggle_signs<cr>', { silent = true })
|
2021-09-28 20:12:29 +08:00
|
|
|
-- lsp stuff
|
2022-08-08 16:40:00 +08:00
|
|
|
map('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>',
|
2022-09-16 17:36:17 +08:00
|
|
|
{ silent = false, noremap = true })
|
|
|
|
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', { noremap = true })
|
2022-08-07 22:57:52 +08:00
|
|
|
map('', '<leader>K', '<cmd>lua vim.diagnostic.open_float()<CR>',
|
2022-09-16 17:36:17 +08:00
|
|
|
{ noremap = true })
|
2022-08-07 21:00:11 +08:00
|
|
|
map('', '<leader>qf',
|
2022-09-16 17:36:17 +08:00
|
|
|
'<cmd>lua vim.diagnostic.setqflist({open = false})<cr><cmd>Telescope quickfix<cr>',
|
|
|
|
{ silent = true })
|
2022-08-07 21:00:11 +08:00
|
|
|
|
2021-11-13 15:29:17 +08:00
|
|
|
-- toggle tagbar
|
2022-09-16 17:36:17 +08:00
|
|
|
map('', '<leader>tt', ':TagbarToggle<cr>', { silent = true })
|
2022-08-07 21:00:11 +08:00
|
|
|
|
2021-09-15 15:18:15 +08:00
|
|
|
-- toggle NvimTree
|
2022-09-16 17:36:17 +08:00
|
|
|
map('', '<C-n>', ':NvimTreeToggle<cr>', { silent = true })
|
2022-08-07 21:00:11 +08:00
|
|
|
|
2021-09-15 15:18:15 +08:00
|
|
|
-- toggle formatter
|
2022-09-16 17:36:17 +08:00
|
|
|
map('', '<leader>fm', ':lua vim.lsp.buf.formatting()<cr>', { silent = true })
|
2022-08-07 21:00:11 +08:00
|
|
|
|
2021-11-13 15:29:17 +08:00
|
|
|
-- toggle Hop
|
2022-09-16 17:36:17 +08:00
|
|
|
map('', '<leader>b', ':HopWordBC<cr>', { silent = true })
|
|
|
|
map('', '<leader>w', ':HopWordAC<cr>', { silent = true })
|
|
|
|
map('', '<leader>l', ':HopWordCurrentLine<cr>', { silent = true })
|
2022-08-07 21:00:11 +08:00
|
|
|
|
2021-11-13 15:29:17 +08:00
|
|
|
-- telescope stuff
|
2022-09-16 17:36:17 +08:00
|
|
|
map('', '<leader>fd', ':Telescope fd<cr>',
|
|
|
|
|
|
|
|
|
|
|
|
{ silent = true })
|
|
|
|
map('', '<leader>tb', ':Telescope buffers<cr>', { silent = true })
|