|
| 1 | +-- vim.keymap.set('n', '!', '_') -- For macos only |
| 2 | + |
| 3 | +-- Center the view when moving |
| 4 | +vim.keymap.set('n', '<C-d>', '<C-d>zz') |
| 5 | +vim.keymap.set('n', '<C-u>', '<C-u>zz') |
| 6 | + |
| 7 | +-- Access to file viewer easily |
| 8 | +vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = '[P]roject files [V]iewer' }) |
| 9 | + |
| 10 | +vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) |
| 11 | +vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) |
| 12 | + |
| 13 | +-- Undotree |
| 14 | +vim.keymap.set('n', '<F5>', vim.cmd.UndotreeToggle) |
| 15 | + |
| 16 | +-- [[ Basic Keymaps ]] |
| 17 | +-- See `:help vim.keymap.set()` |
| 18 | + |
| 19 | +-- Clear highlights on search when pressing <Esc> in normal mode |
| 20 | +-- See `:help hlsearch` |
| 21 | +vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') |
| 22 | + |
| 23 | +-- Diagnostic keymaps |
| 24 | +vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) |
| 25 | + |
| 26 | +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier |
| 27 | +-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which |
| 28 | +-- is not what someone will guess without a bit more experience. |
| 29 | +-- |
| 30 | +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping |
| 31 | +-- or just use <C-\><C-n> to exit terminal mode |
| 32 | +vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }) |
| 33 | + |
| 34 | +-- TIP: Disable arrow keys in normal mode |
| 35 | +vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>') |
| 36 | +vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>') |
| 37 | +vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>') |
| 38 | +vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>') |
| 39 | + |
| 40 | +-- Keybinds to make split navigation easier. |
| 41 | +-- Use CTRL+<hjkl> to switch between windows |
| 42 | +-- |
| 43 | +-- See `:help wincmd` for a list of all window commands |
| 44 | +vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' }) |
| 45 | +vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' }) |
| 46 | +vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) |
| 47 | +vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) |
| 48 | + |
| 49 | +-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes |
| 50 | +-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" }) |
| 51 | +-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" }) |
| 52 | +-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" }) |
| 53 | +-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" }) |
0 commit comments