toggleterm.nvim
toggleterm.nvim copied to clipboard
[Regression] Toggling tabs opens in 'normal mode' and do not close
Noticed this just today.
Sometimes, after using nvim for a while and opening the terminal a few times, when I toggle the terminal it shows NORMAL mode. I have to hit i
to get into TERMINAL mode.
I am on commit 5ea8233 on nvim v0.8.0 dev, not sure the specific dev commit, on ubuntu
@Grazfather this is probably because of the persist_mode = true
and probably using terminal mappings that don't use wincmd
I've added a notice about this in the README but the quickest solution is to set persist mode to false or carefully read the notice I've added and update your config
I've just changed the default for this mode to false by default, since really I guess only people who have set up their mappings for it should be using it.
I've updated to b9f7e08 and the issue still exists, actually, so I don't think that that's it.
In which case, can you provide a minimal init.lua
with steps for me to reproduce this myself.
local execute = vim.api.nvim_command
local fn = vim.fn
local pack_path = fn.stdpath("data") .. "/site/pack"
-- Manually clones a <user>/<repo> from github into the pack directory. Used to
-- bootstrap.
local function ensure (user, repo)
local install_path = string.format("%s/packer/start/%s", pack_path, repo, repo)
if fn.empty(fn.glob(install_path)) > 0 then
execute(string.format("!git clone https://github.com/%s/%s %s", user, repo, install_path))
execute(string.format("packadd %s", repo))
end
end
-- Packer is our plugin manager.
ensure("wbthomason", "packer.nvim")
local ok, packer = pcall(require, "packer")
if not ok then
return
end
packer.startup(function(use)
use {"akinsho/toggleterm.nvim"}
end)
require("toggleterm").setup({open_mapping = "<c-\\>", direction = "tab"})
Simply hit C-\\
three times and you'll be in the terminal in normal mode.
@Grazfather from what I can see in your config you are not using start_in_insert
so there isn't really a reason why the terminal should not start in normal mode. If you just run :terminal
then by default neovim doesn't start a terminal in insert mode. The same applies here unless you set this plugin to behave differently
Well, start_in_insert
defaults to true
, plus, I never needed it before (this seems to be a regression), and finally, setting it to true explicitly does not remediate the issue.
Were you able to reproduce with my init.lua?
I couldn't initially reproduce this using splits, but it seems to specifically reproduce with tabs, although what I'm seeing is more that toggling tabs doesn't work well.
I'll re-open this issue and leave it to track the bug, but I don't have time to look into this currently, so it won't be high on my list. Please feel free to dig in and contribute if it's affecting your workflow.
Thank you for taking a look. I will switch to float in the meantime, and I will try to take a look (though I do not know Vim's lua api very well at all).
@Grazfather can you try the tab mode again and see if it behaves correctly on the latest commit?
To be clear if start_in_insert = false, persist_mode = false
the expected behaviour will be always in normal
mode, unless explicitly set to do it, the terminal does not open in insert mode
I am afraid I still have the issue on commit b402342. Is it fixed for you?
@Grazfather can you clarify the issue exactly again, I'm no longer sure I know what is actually going wrong, do you expect the terminal to be in insert, and it's not despite some settings or vice versa?
I do this:
- Open vim
- Open terminal, it is in insert mode, as expected.
- Toggle the terminal, back to my main buffer.
- Open the terminal now, no longer in insert mode.
@Grazfather are you using start_in_insert = true
and persist_mode = true
?
If not then I would not expect the terminal to be in insert also if you are using persist mode have you changed your terminal mappings as mentioned in the notice in the readme?
Yes I am using those settings. You should be able to repro with my minimal config above.
@Grazfather think this should now be fixed, can you try again.
It seems fixed at 7abb25e!
👍🏿 should be now, seems the issue was that the mode wasn't being reset for tab pages due to a specific edge case
Thanks for the fix!
I was also just running into this issue. That commit works for me, thanks for fixing it!