new layout

main
Dominik Madarász 2024-11-10 17:36:32 +01:00
parent 9500030f56
commit 0d947ddb08
2 changed files with 18 additions and 7 deletions

View File

@ -19,17 +19,28 @@ 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 })
local term_buf = nil
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")
-- If we already have a terminal buffer and it's hidden, reopen it
if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
-- If the terminal is open in the current window, hide it
if vim.api.nvim_get_current_buf() == term_buf then
vim.cmd("close")
else
-- Otherwise, open the terminal buffer in a split at the bottom
vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.25))
vim.api.nvim_set_current_buf(term_buf)
vim.cmd("startinsert")
end
else
-- Open a new terminal at the bottom 25% of the screen
-- If no terminal buffer exists, create a new one
vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.25))
vim.cmd("terminal")
vim.cmd("startinsert")
end
term_buf = vim.api.nvim_get_current_buf() -- Store the terminal buffer ID
end -- Check if the current buffer is a terminal
end
vim.keymap.set("n", "<C-o>", toggleTerminal, { noremap = true, silent = true })

View File

@ -1,7 +1,7 @@
-- Define a custom shortcut that runs when Neovim starts
vim.api.nvim_create_autocmd("UIEnter", {
callback = function()
vim.cmd("vsplit | terminal")
vim.cmd("vsplit | Explore")
vim.cmd("wincmd l")
vim.cmd("Explore")
end,