-- ── keymaps.lua ─────────────────────────────────────────────────────────────── local map = vim.keymap.set local opts = { silent = true } -- ── Escape (tearless mobile ref: jj) ───────────────────────────────────────── map("i", "jj", "", { desc = "Escape insert mode" }) map("i", "jk", "", { desc = "Escape insert mode" }) -- ── File ops (tearless mobile ref) ─────────────────────────────────────────── map("n", "w", "w", { desc = "Save" }) map("n", "q", "q", { desc = "Quit" }) map("n", "x", "wq", { desc = "Save + quit" }) map("n", "Q", "qa!",{ desc = "Force quit all" }) -- ── Clear search highlight ──────────────────────────────────────────────────── map("n", "", "noh", opts) -- ── Better movement ─────────────────────────────────────────────────────────── map("n", "j", "gj", opts) -- visual line movement map("n", "k", "gk", opts) map("n", "H", "^", opts) -- start/end of line map("n", "L", "$", opts) map("n", "", "zz", opts) -- keep cursor centred on scroll map("n", "", "zz", opts) map("n", "n", "nzzzv", opts) -- keep cursor centred on search map("n", "N", "Nzzzv", opts) -- ── Window navigation (matches tmux bindings) ───────────────────────────────── map("n", "", "h", opts) map("n", "", "j", opts) map("n", "", "k", opts) map("n", "", "l", opts) -- ── Window resize ───────────────────────────────────────────────────────────── map("n", "", "resize +2", opts) map("n", "", "resize -2", opts) map("n", "", "vertical resize -2", opts) map("n", "", "vertical resize +2", opts) -- ── Buffer navigation ───────────────────────────────────────────────────────── map("n", "", "bprev", opts) map("n", "", "bnext", opts) map("n", "bd", "bdelete", { desc = "Delete buffer" }) -- ── Indenting keeps selection (tearless mobile ref) ────────────────────────── map("v", "<", "", ">gv", opts) -- ── Move lines ──────────────────────────────────────────────────────────────── map("v", "J", ":m '>+1gv=gv", opts) map("v", "K", ":m '<-2gv=gv", opts) -- ── Paste without losing register ───────────────────────────────────────────── map("v", "p", '"_dP', opts) -- ── File explorer (tearless mobile ref: Ctrl+n) ─────────────────────────────── map("n", "", "Oil", { desc = "File explorer (oil)" }) map("n", "e", "Oil", { desc = "File explorer (oil)" }) -- ── Telescope (tearless mobile ref) ────────────────────────────────────────── map("n", "ff", "Telescope find_files", { desc = "Find files" }) map("n", "fg", "Telescope live_grep", { desc = "Live grep" }) map("n", "fb", "Telescope buffers", { desc = "Buffers" }) map("n", "fh", "Telescope help_tags", { desc = "Help tags" }) map("n", "fd", "Telescope diagnostics", { desc = "Diagnostics" }) map("n", "fr", "Telescope oldfiles", { desc = "Recent files" }) map("n", "fs", "Telescope lsp_document_symbols",{ desc = "Symbols" }) -- ── LSP (set globally; lsp.lua on_attach adds buffer-local too) ─────────────── map("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" }) map("n", "gD", vim.lsp.buf.declaration, { desc = "Go to declaration" }) map("n", "gr", "Telescope lsp_references",{ desc = "References" }) map("n", "gi", vim.lsp.buf.implementation, { desc = "Implementation" }) map("n", "K", vim.lsp.buf.hover, { desc = "Hover docs" }) map("n", "", vim.lsp.buf.signature_help, { desc = "Signature help" }) map("n", "rn", vim.lsp.buf.rename, { desc = "Rename symbol" }) map("n", "ca", vim.lsp.buf.code_action, { desc = "Code action" }) map("n", "f", function() vim.lsp.buf.format({ async = true }) end, { desc = "Format buffer" }) -- ── Diagnostics ─────────────────────────────────────────────────────────────── map("n", "[d", vim.diagnostic.goto_prev, { desc = "Prev diagnostic" }) map("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" }) map("n", "dl", vim.diagnostic.open_float, { desc = "Line diagnostics" }) -- ── Leap (info only — sets its own mappings) ───────────────────────────────── -- s → leap (n/x/o) -- S → leap-from-window (n) -- Surround defaults (v4): ys{motion}{char}, ds{char}, cs{old}{new} -- ── LazyGit ─────────────────────────────────────────────────────────────────── map("n", "g", "LazyGit", { desc = "LazyGit" }) -- ── Which-key group labels ──────────────────────────────────────────────────── local ok, wk = pcall(require, "which-key") if ok then wk.add({ { "f", group = "find / telescope" }, { "d", group = "diagnostics" }, { "b", group = "buffer" }, }) end