Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open multiple terminals while in terminal mode #533

Open
ivanovaleksandar opened this issue Jan 18, 2024 · 3 comments
Open

Cannot open multiple terminals while in terminal mode #533

ivanovaleksandar opened this issue Jan 18, 2024 · 3 comments

Comments

@ivanovaleksandar
Copy link

ivanovaleksandar commented Jan 18, 2024

Current Behavior

The current setup allow me to spawn multiple terminals, just like expected, meaning that 1<c-t> and 2<c-t> opens terminal 1 and 2 respectively. The current issue is that doing 1<c-t> and then 2<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:

lvim.keys.normal_mode["<c-t>"] = false
lvim.builtin.terminal.open_mapping = "<c-t>"
lvim.builtin.terminal.active = true

  {
    "akinsho/toggleterm.nvim",
    config = function()
      require("toggleterm").setup({
        open_mapping = [[<c-t>]],
        terminal_mappings = true,
        direction = "horizontal",
        size = 30,
      })
    end
  }

Environment

- OS: MacOS Sonoma 14.1.1 (23B81)
- neovim version: 0.9.0
- Shell: zsh

Anything else?

No response

@tarunaksha
Copy link

So I wanted to get the results as shown here:

toggletermgif

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...

init.lua

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

lua/plugins/toggleterm.lua

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:
Screenshot from 2024-01-28 18-14-36

@blurskye

This comment was marked as off-topic.

@JoshBenn
Copy link

JoshBenn commented Mar 26, 2024

It doesn't open in terminal mode, but here's my lazy config for this:
image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants