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 local b = function() return require 'telescope.builtin' end local lws = function() return b().lsp_workspace_symbols() end local ldws = function() return b().lsp_dynamic_workspace_symbols() end K.n('', ':lua vim.lsp.buf.signature_help()', { desc = 'Signature' }) K.n('K', ':lua vim.lsp.buf.hover()', { desc = 'Hover Documentation' }) K.ld('ca', 'n', ':lua vim.lsp.buf.code_action()', 'Code Action') K.ld('cci', 'n', function() b().lsp_incoming_calls() end, 'Incoming calls') K.ld('cco', 'n', function() b().lsp_outgoing_calls() end, 'Outgoing calls') K.ld('cd', 'n', function() b().lsp_definitions() end, 'Definitions') 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', function() b().lsp_implementations() end, 'Implementations') K.ld('cp', 'n', function() b().lsp_type_definitions() end, 'Type Definition') K.ld('cr', 'n', vim.lsp.buf.rename, 'Rename') K.ld('cs', 'n', ':Telescope lsp_document_symbols', 'LSP Document Symbols') K.ld('ct', 'n', function() b().treesitter() end, 'treesitter') K.ld('cws', 'n', function() lws() end, 'Workspace Symbols') K.ld('cwd', 'n', function() ldws() end, 'Dynamic Workspace Symbols') -- ── 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 local lazy_plugins = function() return require('telescope').extensions.lazy_plugins.lazy_plugins() end K.nl('f', function() require('fff').find_files() end, 'Find Files') K.nl(',', ':Telescope buffers', 'Find existing buffers') K.nl('sd', ':Telescope diagnostics', 'Search Diagnostics') K.nl('sf', ':Telescope grep_string', 'Grep String') K.nl('sh', ':Telescope help_tags', 'Help tags') K.nl('sk', ':Telescope keymaps', 'Search Keymaps') K.nl('so', ':Telescope oldfiles', 'Old Files') K.nl('sp', function() lazy_plugins() end, 'Lazy Plugins') K.nl('sq', ':Telescope quickfix', 'Quickfix') K.nl('ss', ':Telescope treesitter', 'Treesitter') K.nl('sx', ':Telescope import', 'Telescope: Import') -- ── Trouble operations ────────────────────────────────────────────── -- Convention is 'x' followed by the operation K.nl('xd', ':Trouble 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.