Open jemag opened 12 months ago
I have a very similar configuration where I can switch between multiple floating terminals and I also have issues with the mode not being consistent. I want every terminal to be back in insert when it is opened. Therefore, I tried calling vim.cmd('startinsert!')
in the on_open callback but as far as I can tell this doesn't. As a work around I am using a timer with a very short delay in the callback:
vim.fn.timer_start(1, function()
vim.cmd('startinsert!')
end)
Maybe this is somehow related.
I have a very similar configuration where I can switch between multiple floating terminals and I also have issues with the mode not being consistent. I want every terminal to be back in insert when it is opened. Therefore, I tried calling
vim.cmd('startinsert!')
in the on_open callback but as far as I can tell this doesn't. As a work around I am using a timer with a very short delay in the callback:vim.fn.timer_start(1, function() vim.cmd('startinsert!') end)
Maybe this is somehow related.
Was struggling with the same thing. Although not ideal, thanks for the workaround.
Is there an existing issue for this?
Current Behavior
Calling
toggle
twice in quick succession will not respectpersist_mode
/start_in_insert
Expected Behavior
No amount of
toggle
calling changes the behavior.Steps To Reproduce
nvim -u repro.lua somerandomfile
:-- set stdpaths to use .repro for , name in ipairs({ "config", "data", "state", "cache" }) do vim.env[("XDG%s_HOME"):format(name:upper())] = root .. "/" .. name end
-- bootstrap lazy local lazypath = root .. "/plugins/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", lazypath }) end vim.opt.runtimepath:prepend(lazypath) vim.g.mapleader = " "
-- install plugins local plugins = { "folke/tokyonight.nvim", -- add any other plugins here }
local toggleterm_config = { "akinsho/toggleterm.nvim", config = function() require("toggleterm").setup({ shading_factor = "0", hide_numbers = false, persist_mode = true, start_in_insert = true, direction = "float", size = function(term) if term.direction == "horizontal" then return vim.o.lines 0.5 elseif term.direction == "vertical" then return vim.o.columns 0.5 end end, })
end, }
table.insert(plugins, toggleterm_config) require("lazy").setup(plugins, { root = root .. "/plugins", })
vim.cmd.colorscheme("tokyonight") -- add anything else here
Anything else?
Here is a video of the
Steps to Reproduce
section: https://github.com/akinsho/toggleterm.nvim/assets/7985687/a7c5e75d-609a-4c3b-a2ea-f490add9039c Note that this behavior will happen also when calling toggle on the same terminal twice in succession as well, e.g.:It also happens if we call the
:{count}ToggleTerm
twice in quick succession as well.Why does that matter?
I think being able to call it in quick succession can be useful for some key bindings. For example. I was trying to setup the following keybinds to cycle through my current floating terminals: