-- Custom keymaps local map = vim.keymap.set -- Terminal keymaps -- th - Open terminal in horizontal split map("n", "th", function() vim.cmd("split | terminal") vim.cmd("startinsert") end, { desc = "Terminal (horizontal split)" }) -- tv - Open terminal in vertical split map("n", "tv", function() vim.cmd("vsplit | terminal") vim.cmd("startinsert") end, { desc = "Terminal (vertical split)" }) -- Terminal mode: Escape to normal mode map("t", "", "", { desc = "Exit terminal mode" }) -- Explorer keymaps (Snacks explorer) -- Ctrl+Shift+e - Toggle explorer map("n", "", function() Snacks.explorer() end, { desc = "Toggle Explorer" }) map("i", "", function() Snacks.explorer() end, { desc = "Toggle Explorer" }) -- Note: Ctrl+Shift+v and Ctrl+Shift+h for opening files in splits -- are configured in the snacks picker config (lua/plugins/editor.lua) -- as they need to work within the explorer buffer context -- Additional useful keymaps -- Better window navigation map("n", "", "h", { desc = "Go to left window" }) map("n", "", "j", { desc = "Go to lower window" }) map("n", "", "k", { desc = "Go to upper window" }) map("n", "", "l", { desc = "Go to right window" }) -- Resize windows with arrows map("n", "", "resize +2", { desc = "Increase window height" }) map("n", "", "resize -2", { desc = "Decrease window height" }) map("n", "", "vertical resize -2", { desc = "Decrease window width" }) map("n", "", "vertical resize +2", { desc = "Increase window width" }) -- Buffer navigation map("n", "", "bprevious", { desc = "Prev buffer" }) map("n", "", "bnext", { desc = "Next buffer" }) -- Clear search highlight map("n", "", "nohlsearch", { desc = "Clear search highlight" }) -- Save file map({ "n", "i", "v", "s" }, "", "w", { desc = "Save file" }) -- Better indenting in visual mode map("v", "<", "", ">gv") -- Move lines up/down map("n", "", "m .+1==", { desc = "Move line down" }) map("n", "", "m .-2==", { desc = "Move line up" }) map("v", "", ":m '>+1gv=gv", { desc = "Move selection down" }) map("v", "", ":m '<-2gv=gv", { desc = "Move selection up" }) -- Quick access to AI chat map("n", "aa", "AvanteAsk", { desc = "AI Ask" }) map("v", "aa", "AvanteAsk", { desc = "AI Ask (selection)" }) map("n", "ac", "AvanteChat", { desc = "AI Chat" }) map("n", "at", "AvanteToggle", { desc = "AI Toggle" }) -- Database keymaps map("n", "db", "DBUIToggle", { desc = "Toggle DB UI" }) map("n", "da", "DBUIAddConnection", { desc = "Add DB Connection" }) -- Neotest local neotest = require("neotest") map("n", "tt", neotest.run.run, { desc = "Run nearest test" }) map("n", "tf", function() neotest.run.run(vim.fn.expand("%")) end, { desc = "Run test file" }) map("n", "ts", neotest.summary.toggle) map("n", "to", neotest.output.open) map("n", "tc", "Coverage", { desc = "Show coverage" }) -- Go benchmark map("n", "gb", function() vim.cmd("!go test -bench . ./...") end, { desc = "Go benchmarks" }) map("n", "gp", function() vim.cmd("!go test -cpuprofile cpu.out && go tool pprof cpu.out") end, { desc = "Go CPU profile" }) -- Overseer map("n", "or", "OverseerRun", { desc = "Run task" }) map("n", "ot", "OverseerToogle", { desc = "Task list" }) -- Aerial map("n", "so", "AerialToggle", { desc = "Symbols outline" }) map("n", "sh", vim.lsp.buf.incoming_calls, { desc = "Incoming calls" }) map("n", "sc", vim.lsp.buf.outgoing_calls, { desc = "Outgoing calls" }) -- Diagnostics map("n", "xx", "Trouble diagnostics toggle") map("n", "xw", "Trouble workspace_diagnostics") map("n", "xt", "Trouble todo")