fix: only bind Esc→normal in shell, not TUI programs (Reasonix/lazygit)
This commit is contained in:
parent
23984f2756
commit
a26dc1a51a
|
|
@ -50,11 +50,14 @@ function M.open(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not terms[name] then
|
if not terms[name] then
|
||||||
terms[name] = require('toggleterm.terminal').Terminal:new(vim.tbl_extend('force', opts, {
|
local extra = {}
|
||||||
on_open = function(term)
|
-- 只在普通 shell 绑 Esc → normal,Reasonix/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 })
|
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
|
end
|
||||||
|
|
||||||
terms[name]:toggle()
|
terms[name]:toggle()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue