max397574/better-escape.nvim

terminal escape mode not working

Closed this issue · 6 comments

Insert mode and Visual mode are working by default but it seems terminal mode isn't escaping with jk as expected. Likely user error but not sure.

reproduction.lua

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    {
        "max397574/better-escape.nvim",
        config = true,
    },
  },
})

nvim -u reproduction.lua -c "split | terminal"

Typing jk in the terminal buffer doesn't escape terminal mode back into normal mode

Well it will just simulate whatever you mapped. By default it is like pressing esc. For me this puts me just in the normal mode of the fish vim emulation
I get errors with my shell when using this repro (not your fault)
but I think everything works correctly here.
It shouldn't put you back to normal mode in all cases but just do what happens when you press <esc>. Could you confirm this is the case?

I think it makes sense to use jk to escape from terminal mode to normal mode when in terminal buffer. Have tried something like:

		t = {
			j = {
				k = function()
                                vim.api.nvim_input([[<C-\><C-n>]])
                                -- vim.cmd([[normal <C-\><C-n>]])
				end,
				-- k = "<Esc>",
			},
		},

but seems none is working but only sending <Esc>.

I think it makes sense to use jk to escape from terminal mode to normal mode when in terminal buffer. Have tried something like:

		t = {
			j = {
				k = function()
                                vim.api.nvim_input([[<C-\><C-n>]])
                                -- vim.cmd([[normal <C-\><C-n>]])
				end,
				-- k = "<Esc>",
			},
		},

but seems none is working but only sending <Esc>.

The above is actually working fine. I accidentally setup better-escape twice in my configure.

You can directly pass the key:

t = {
    j = {
        k = [[<C-\><C-n>]],
    },
},

Well it will just simulate whatever you mapped. By default it is like pressing esc. For me this puts me just in the normal mode of the fish vim emulation

But didn't that change in #84 ?

could be
I think with the new default it makes much more sense