add term toggle
parent
70efa980c0
commit
9500030f56
|
@ -19,11 +19,23 @@ vim.keymap.set("n", "<C-m>", "<C-6>")
|
|||
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { noremap = true, silent = true })
|
||||
-- vim.keymap.set("n", "<leader>;", ":vsplit term://left<CR><A-Right><CR>", { noremap = true, silent = true })
|
||||
|
||||
vim.keymap.set("n", "<C-k>", 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", "<C-o>", toggleTerminal, { noremap = true, silent = true })
|
||||
vim.keymap.set("v", "<C-o>", toggleTerminal, { noremap = true, silent = true })
|
||||
vim.keymap.set("i", "<C-o>", toggleTerminal, { noremap = true, silent = true })
|
||||
vim.keymap.set("t", "<C-o>", toggleTerminal, { noremap = true, silent = true })
|
||||
|
||||
-- Terminal mode mappings (Alt + hjkl and Alt + Arrow Keys)
|
||||
vim.api.nvim_set_keymap('t', '<A-h>', '<C-\\><C-N><C-w>h', { noremap = true, silent = true })
|
||||
|
|
Loading…
Reference in New Issue