| 1 | local opts = { noremap = true, silent = true } |
| 2 | local map = vim.api.nvim_set_keymap |
| 3 | |
| 4 | -- Saving |
| 5 | map("n", "++", "<cmd>write!<CR>", opts) |
| 6 | |
| 7 | -- Tmux Navigation |
| 8 | map("n", "<C-h>", "<cmd>TmuxNavigateLeft<CR>", opts) |
| 9 | map("n", "<C-j>", "<cmd>TmuxNavigateDown<CR>", opts) |
| 10 | map("n", "<C-k>", "<cmd>TmuxNavigateUp<CR>", opts) |
| 11 | map("n", "<C-l>", "<cmd>TmuxNavigateRight<CR>", opts) |
| 12 | |
| 13 | -- Navigation |
| 14 | map("n", "j", "gj", opts) |
| 15 | map("n", "k", "gk", opts) |
| 16 | map("n", "n", "nzzzv", opts) |
| 17 | map("n", "N", "Nzzzv", opts) |
| 18 | map("n", "<C-d>", "<C-d>zz", opts) |
| 19 | map("n", "<C-u>", "<C-u>zz", opts) |
| 20 | |
| 21 | -- Buffers |
| 22 | map("n", "<S-l>", ":bnext<CR>", opts) |
| 23 | map("n", "<S-h>", ":bprevious<CR>", opts) |
| 24 | map("n", "<leader>o", "<cmd>Pick buffers<CR>", opts) |
| 25 | map("n", "<leader>c", ":bd<cr>", opts) |
| 26 | |
| 27 | -- Quickfix |
| 28 | map("n", "<C-n>", "<cmd>cnext<CR>zz", opts) |
| 29 | map("n", "<C-m>", "<cmd>cprev<CR>zz", opts) |
| 30 | map("n", "<leader>q", "<cmd>copen<CR>", opts) |
| 31 | map("n", "<leader>a", "<cmd>cclose<CR>", opts) |
| 32 | |
| 33 | -- Search |
| 34 | map("n", "<leader>h", "<cmd>nohlsearch<CR>", opts) |
| 35 | map("n", "<leader>f", "<cmd>Pick files<CR>", opts) |
| 36 | map("n", "<leader>/", "<cmd>Pick grep_live<CR>", opts) |
| 37 | map("n", "<leader>hh", "<cmd>Pick help<CR>", opts) |
| 38 | |
| 39 | -- Diagnostics |
| 40 | map("n", "<leader>d", "<cmd>Pick diagnostic<CR>", opts) |
| 41 | |
| 42 | -- Git |
| 43 | map("n", "<leader>gg", "<cmd>lua MiniDiff.toggle_overlay()<CR>", opts) |
| 44 | |
| 45 | -- File explorer |
| 46 | map("n", "<leader>e", "<cmd>lua MiniFiles.open()<CR>", opts) |
| 47 | |
| 48 | -- Spelling |
| 49 | vim.keymap.set("n", "<leader>s", function() |
| 50 | local word = vim.fn.expand("<cword>") |
| 51 | local suggestions = vim.fn.spellsuggest(word, 25) |
| 52 | MiniPick.start({ |
| 53 | source = { |
| 54 | items = suggestions, |
| 55 | name = "Spelling: " .. word, |
| 56 | choose = function(item) |
| 57 | vim.schedule(function() |
| 58 | vim.cmd("normal! ciw" .. item) |
| 59 | vim.cmd("stopinsert") |
| 60 | end) |
| 61 | end, |
| 62 | }, |
| 63 | }) |
| 64 | end, { desc = "Spelling suggestions" }) |
| 65 | |
| 66 | -- Editing |
| 67 | map("n", "J", "mzJ`z", opts) |
| 68 | map("n", "YY", "va{Vy", opts) |
| 69 | map("x", "p", '"_dP', opts) |
| 70 | |
| 71 | -- Insert mode |
| 72 | map("i", "jj", "<ESC>", opts) |
| 73 | map("i", "jk", "<ESC>", opts) |
| 74 | map("i", "<C-j>", 'pumvisible() ? "\\<C-n>" : "\\<C-j>"', { expr = true, noremap = true, silent = true }) |
| 75 | map("i", "<C-k>", 'pumvisible() ? "\\<C-p>" : "\\<C-k>"', { expr = true, noremap = true, silent = true }) |
| 76 | |
| 77 | -- Visual mode |
| 78 | map("v", "<", "<gv", opts) |
| 79 | map("v", ">", ">gv", opts) |
| 80 | map("v", "J", ":m '>+1<CR>gv=gv", opts) |
| 81 | map("v", "K", ":m '<-2<CR>gv=gv", opts) |