fix: only bind Esc→normal in shell, not TUI programs (Reasonix/lazygit)

This commit is contained in:
QQ 2026-06-11 21:01:03 +08:00
parent 23984f2756
commit a26dc1a51a
1 changed files with 7 additions and 4 deletions

View File

@ -50,11 +50,14 @@ function M.open(cmd)
end
if not terms[name] then
terms[name] = require('toggleterm.terminal').Terminal:new(vim.tbl_extend('force', opts, {
on_open = function(term)
local extra = {}
-- 只在普通 shell 绑 Esc → normalReasonix/lazygit 等 TUI 程序保留原生 <C-\><C-n>
if name == '__shell__' then
extra.on_open = function(term)
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { buffer = term.bufnr, noremap = true })
end,
}))
end
end
terms[name] = require('toggleterm.terminal').Terminal:new(vim.tbl_extend('force', opts, extra))
end
terms[name]:toggle()