-- 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" })