Open ivanovaleksandar opened 9 months ago
So I wanted to get the results as shown here:
I looked for this configuration in several platforms like reddit,youtube,stackexchange etc. but didn't find the proper solution. After brainstorming(as I am new to vim) for hours I finally figured it for my usecase.
i am using lazy-vim
currently.
Here are my setups to achieve this...
require("config.lazy")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"akinsho/toggleterm.nvim",
config = function()
require("toggleterm").setup()
end,
},
})
return {
"akinsho/toggleterm.nvim",
version = "*",
config = true,
opts = {
size = 12,
open_mapping = [[<c-\>]],
shade_filetypes = {},
shade_terminals = true,
shading_factor = 1,
start_in_insert = true,
persist_size = true,
close_on_exit = true,
direction = "horizontal",
},
}
Pretty straight-forward and default setup. I use ctrl+\
for opening the terminal horizontally and open another terminal by pressing 2+ctrl+\
. For 3rd 3+....
and so on (who needs more than 3). To hide them press ctrl+\
again. To exit them simply type "exit". For giving input in terminal press "i" and press "esc" two times to revert to normal mode. Switching between them is also similar like normal vim mode.
Here is my result:
i would highly recomend using something like tmux or a alternative to it for terminal multiplexing....
It doesn't open in terminal mode, but here's my lazy config for this:
While you have to press <Esc>
in terminal mode, it gives access to <leader>tt
(or whatever you want to set it as) for creating new terminals and <leader>te
for exiting them. Also gives you <c-\>
for toggling horizontal windows and <c-]>
for floating ones.
Current Behavior
The current setup allow me to spawn multiple terminals, just like expected, meaning that
1<c-t>
and2<c-t>
opens terminal 1 and 2 respectively. The current issue is that doing1<c-t>
and then2<c-t>
, the terminal does not split in two, but instead closes the terminal, same as doing<c-t>
.Is I do this with command
:ToggleTerm 1
and:ToggleTerm 2
it works like expected.Expected Behavior
The expected behaviour is that spawning a second terminal, the screen will split the screen of the first terminal and open the second one.
Steps To Reproduce
Using lazyvim with lunarvim, this is the current relevant config:
Environment
Anything else?
No response