diff --git a/lua/zak/remap.lua b/lua/zak/remap.lua index 24a2568..b49cf44 100644 --- a/lua/zak/remap.lua +++ b/lua/zak/remap.lua @@ -19,11 +19,23 @@ vim.keymap.set("n", "", "") vim.keymap.set("t", "", "", { noremap = true, silent = true }) -- vim.keymap.set("n", ";", ":vsplit term://left", { noremap = true, silent = true }) -vim.keymap.set("n", "", function () +function toggleTerminal() + -- Check if the current buffer is a terminal + if vim.bo.buftype == "terminal" then + -- Close the terminal if we're already in one + vim.cmd("close") + else + -- Open a new terminal at the bottom 25% of the screen vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.25)) vim.cmd("terminal") vim.cmd("startinsert") -end) + end +end + +vim.keymap.set("n", "", toggleTerminal, { noremap = true, silent = true }) +vim.keymap.set("v", "", toggleTerminal, { noremap = true, silent = true }) +vim.keymap.set("i", "", toggleTerminal, { noremap = true, silent = true }) +vim.keymap.set("t", "", toggleTerminal, { noremap = true, silent = true }) -- Terminal mode mappings (Alt + hjkl and Alt + Arrow Keys) vim.api.nvim_set_keymap('t', '', 'h', { noremap = true, silent = true })