fix: map <Esc> to <C-\><C-n> in terminal buffers so Esc exits to normal mode

This commit is contained in:
QQ 2026-06-11 20:56:56 +08:00
parent 977384ccda
commit 23984f2756
1 changed files with 5 additions and 1 deletions

View File

@ -50,7 +50,11 @@ function M.open(cmd)
end
if not terms[name] then
terms[name] = require('toggleterm.terminal').Terminal:new(opts)
terms[name] = require('toggleterm.terminal').Terminal:new(vim.tbl_extend('force', opts, {
on_open = function(term)
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { buffer = term.bufnr, noremap = true })
end,
}))
end
terms[name]:toggle()