-- vim: set ft=lua ts=2 sw=2 tw=0 et cc=120 : require('utils') -- ╭─────────────────────────────────────────────────────────╮ -- │ Keymaps │ -- ╰─────────────────────────────────────────────────────────╯ -- ── Disable arrow keys in normal mode ─────────────────────────────── K.n('', ':echo "Use h to move!!"') K.n('', ':echo "Use l to move!!"') K.n('', ':echo "Use k to move!!"') K.n('', ':echo "Use j to move!!"') -- ── Splits ────────────────────────────────────────────────────────── K.n(',', ':vertical resize -10', { desc = 'V Resize -' }) K.n('.', ':vertical resize +10', { desc = 'V Resize +' }) K.n('-', ':resize -10', { desc = 'H Resize -' }) K.n('+', ':resize +10', { desc = 'H Resize +' }) K.n('=', '=', { desc = 'Equal Size Splits' }) -- ── Deal with word wrap ───────────────────────────────────────────── K.n('k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Move up', noremap = true, expr = true }) K.n('j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Move down', noremap = true, expr = true }) -- ── Text manipulation ─────────────────────────────────────────────── K.d('<', { 'n', 'v' }, '', { 'n', 'v' }, '>gv', 'Indent Right') K.d('', { 'n', 'v' }, ":m '<-2gv=gv", 'Move Block Up') K.d('', { 'n', 'v' }, ":m '>+1gv=gv", 'Move Block Down') -- ── Other operations ──────────────────────────────────────────────── K.nl('o', function() require('snacks').gitbrowse() end, 'Open repo in browser') K.n('', ':w!', { desc = 'Save', noremap = true }) K.n('', ':nohlsearch', { desc = 'Clear Search Highlighting' }) -- ── Buffer operations ─────────────────────────────────────────────── -- Mappings for buffer management operations like switching, deleting, etc. -- Convention: All mappings start with 'b' followed by the operation K.nl('ba', ':%bd|e#|bd#', 'Close all except current') K.nl('bd', ':lua MiniBufremove.delete()', 'Delete') K.nl('bh', ':bprev', 'Prev') K.nl('bj', ':bfirst', 'First') K.nl('bk', ':blast', 'Last') K.nl('bl', ':bnext', 'Next') K.nl('bw', ':lua MiniBufremove.wipeout()', 'Wipeout') -- ── Code & LSP operations ─────────────────────────────────────────── -- Mappings for code and LSP operations like code actions, formatting, etc. -- Convention: All mappings start with 'c' followed by the operation -- unless it's a generic operation like signature help or hover K.n('', ':lua vim.lsp.buf.signature_help()', { desc = 'Signature' }) K.n('K', ':Lspsaga hover_doc', { desc = 'Hover Documentation' }) K.ld('ca', 'n', ':Lspsaga code_action', 'Code Action') K.ld('cci', 'n', ':Lspsaga incoming_calls', 'Incoming Calls') K.ld('cco', 'n', ':Lspsaga outgoing_calls', 'Outgoing Calls') K.ld('cd', 'n', ':Lspsaga show_line_diagnostics', 'Line Diagnostics') K.ld('cf', { 'n', 'x' }, ':lua vim.lsp.buf.format()', 'Format') K.ld('cg', 'n', ':lua require("neogen").generate()', 'Generate annotations') K.ld('ci', 'n', ':Lspsaga implement', 'Implementations') K.ld('cl', 'n', ':Lspsaga show_cursor_diagnostics', 'Cursor Diagnostics') K.ld('cp', 'n', ':Lspsaga peek_definition', 'Peek Definition') K.ld('cr', 'n', ':Lspsaga rename', 'Rename') K.ld('cR', 'n', ':Lspsaga rename ++project', 'Rename Project wide') K.ld('cs', 'n', ':Telescope lsp_document_symbols', 'LSP Document Symbols') K.ld('ct', 'n', ':Lspsaga peek_type_definition', 'Peek Type Definition') K.ld('cT', 'n', ':Telescope lsp_type_definitions', 'LSP Type Definitions') K.ld('cu', 'n', ':Lspsaga preview_definition', 'Preview Definition') K.ld('cv', 'n', ':Lspsaga diagnostic_jump_prev', 'Diagnostic Jump Prev') K.ld('cw', 'n', ':Lspsaga diagnostic_jump_next', 'Diagnostic Jump Next') -- ── CommentBox operations ─────────────────────────────────────────── -- Mappings for creating and managing comment boxes -- Convention: All mappings start with 'cb' followed by the box type K.nl('cbb', 'CBccbox', 'CB: Box Title') K.nl('cbd', 'CBd', 'CB: Remove a box') K.nl('cbl', 'CBline', 'CB: Simple Line') K.nl('cbm', 'CBllbox14', 'CB: Marked') K.nl('cbt', 'CBllline', 'CB: Titled Line') -- ── Telescope operations ──────────────────────────────────────────── -- Mappings for Telescope operations like finding files, buffers, etc. -- Convention: All mappings start with 's' followed by the operation -- unless it's a generic operation like searching or finding buffers K.nl('f', ':Telescope find_files', 'Find Files') K.nl(',', ':Telescope buffers', 'Find existing buffers') K.nl('/', function() require('telescope.builtin').current_buffer_fuzzy_find( require('telescope.themes').get_dropdown { winblend = 20, previewer = true, } ) end, 'Fuzzily search in current buffer') K.nl('sc', ':Telescope commands', 'Commands') K.nl('sd', ':Telescope diagnostics', 'Search Diagnostics') K.nl('sg', ':Telescope live_grep', 'Search by Grep') K.nl('sh', ':Telescope help_tags', 'Help tags') K.nl('sk', ':Telescope keymaps', 'Search Keymaps') K.nl('sl', ':Telescope luasnip', 'Search LuaSnip') K.nl('so', ':Telescope oldfiles', 'Old Files') K.nl('sp', ':lua require("telescope").extensions.lazy_plugins.lazy_plugins()', 'Lazy Plugins') K.nl('sq', ':Telescope quickfix', 'Quickfix') K.nl('ss', ':Telescope treesitter', 'Treesitter') K.nl('st', ':TodoTelescope', 'Search Todos') K.nl('sw', ':Telescope grep_string', 'Grep String') K.nl('sx', ':Telescope import', 'Telescope: Import') -- ── Trouble operations ────────────────────────────────────────────── -- Convention is 'x' followed by the operation K.nl('xd', ':Trouble document_diagnostics', 'Document Diagnostics') K.nl('xl', ':Trouble loclist', 'Location List') K.nl('xq', ':Trouble quickfix', 'Quickfix') K.nl('xw', ':Trouble workspace_diagnostics', 'Workspace Diagnostics') K.nl('xx', ':Trouble diagnostics', 'Diagnostic') -- ── Toggle settings ───────────────────────────────────────────────── -- Convention is 't' followed by the operation K.nl('tc', ':CloakToggle', 'Cloak: Toggle') K.nl('te', ':Neotree toggle', 'Toggle Neotree') K.nl('tl', ToggleBackground, 'Toggle Light/Dark Mode') K.nl('tn', ':Noice dismiss', 'Noice: Dismiss Notification') -- ── Quit operations ───────────────────────────────────────────────── -- Convention is 'q' followed by the operation K.nl('qf', ':q', 'Quicker close split') K.nl('qq', function() if vim.fn.confirm("Force save and quit?", "&Yes\n&No", 2) == 1 then vim.cmd('wq!') end end, 'Quit with force saving') K.nl('qw', ':wq', 'Write and quit') K.nl('qQ', function() if vim.fn.confirm("Force quit without saving?", "&Yes\n&No", 2) == 1 then vim.cmd('q!') end end, 'Force quit without saving') -- That concludes the keymaps section of the config.