more navigation fixes (primarly disabling mouse when terminal is open)
This commit is contained in:
@@ -195,29 +195,30 @@ vim.keymap.set("n", "<A-h>", function() wrap_move("h") end, { desc = "Move to le
|
||||
vim.keymap.set("n", "<A-l>", function() wrap_move("l") end, { desc = "Move to right pane (wrap)" })
|
||||
vim.keymap.set("n", "<A-j>", function() wrap_move("j") end, { desc = "Move to pane below (wrap)" })
|
||||
vim.keymap.set("n", "<A-k>", function() wrap_move("k") end, { desc = "Move to pane above (wrap)" })
|
||||
-- Alt+h/l in terminal: switch terminal tabs if popup is open, otherwise move panes
|
||||
-- Alt+h/l in terminal: only switch terminal tabs in popup, no pane navigation
|
||||
vim.keymap.set("t", "<A-h>", function()
|
||||
if popup_term.win and vim.api.nvim_win_is_valid(popup_term.win) then
|
||||
switch_term((popup_term.current - 2) % #popup_term.bufs + 1)
|
||||
else
|
||||
vim.cmd("stopinsert") wrap_move("h")
|
||||
end
|
||||
end, { desc = "Prev term tab / left pane" })
|
||||
end, { desc = "Prev term tab" })
|
||||
vim.keymap.set("t", "<A-l>", function()
|
||||
if popup_term.win and vim.api.nvim_win_is_valid(popup_term.win) then
|
||||
switch_term(popup_term.current % #popup_term.bufs + 1)
|
||||
else
|
||||
vim.cmd("stopinsert") wrap_move("l")
|
||||
end
|
||||
end, { desc = "Next term tab / right pane" })
|
||||
vim.keymap.set("t", "<A-j>", function()
|
||||
if popup_term.win and vim.api.nvim_win_is_valid(popup_term.win) then return end
|
||||
vim.cmd("stopinsert") wrap_move("j")
|
||||
end, { desc = "Move to pane below (wrap)" })
|
||||
vim.keymap.set("t", "<A-k>", function()
|
||||
if popup_term.win and vim.api.nvim_win_is_valid(popup_term.win) then return end
|
||||
vim.cmd("stopinsert") wrap_move("k")
|
||||
end, { desc = "Move to pane above (wrap)" })
|
||||
end, { desc = "Next term tab" })
|
||||
-- Block pane navigation in terminal mode
|
||||
vim.keymap.set("t", "<A-j>", "<Nop>")
|
||||
vim.keymap.set("t", "<A-k>", "<Nop>")
|
||||
|
||||
-- Disable mouse when terminal is focused, restore on leave
|
||||
vim.api.nvim_create_autocmd("TermEnter", {
|
||||
group = vim.api.nvim_create_augroup("term_no_mouse", { clear = true }),
|
||||
callback = function() vim.o.mouse = "" end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("TermLeave", {
|
||||
group = vim.api.nvim_create_augroup("term_restore_mouse", { clear = true }),
|
||||
callback = function() vim.o.mouse = "a" end,
|
||||
})
|
||||
|
||||
-- Terminal copy/paste
|
||||
vim.keymap.set("t", "<C-v>", function()
|
||||
@@ -227,7 +228,17 @@ vim.keymap.set("t", "<C-v>", function()
|
||||
end
|
||||
end, { desc = "Paste from clipboard" })
|
||||
vim.keymap.set("t", "<C-y>", [[<C-\><C-n>V]], { desc = "Select current line (normal mode)" })
|
||||
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]], { desc = "Exit to normal mode" })
|
||||
|
||||
-- Auto-enter insert mode when switching to a terminal window
|
||||
-- Uses WinEnter only (not BufEnter) so :wq from nested editors (e.g. git commit) works
|
||||
vim.api.nvim_create_autocmd("WinEnter", {
|
||||
group = vim.api.nvim_create_augroup("term_auto_insert", { clear = true }),
|
||||
callback = function()
|
||||
if vim.bo.buftype == "terminal" and vim.fn.mode() ~= "t" then
|
||||
vim.cmd.startinsert()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Save/restore layout with :mksession
|
||||
vim.opt.sessionoptions = "buffers,curdir,folds,winpos,winsize,terminal"
|
||||
|
||||
Reference in New Issue
Block a user