fix(nvim): auto-insert in terminal buffers, add terminal window nav

- BufEnter term://* auto-calls startinsert so alot/abook receive keys
  immediately without needing to press i/a first (skips floaterm)
- <C-hjkl> in terminal-insert mode exits to normal then moves window,
  matching the existing normal-mode nav mappings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-05-26 13:35:31 +02:00
parent ddd632fb7e
commit 50c5b72683
1 changed files with 17 additions and 1 deletions

View File

@ -87,12 +87,28 @@ vim.opt.wildmenu = true
vim.opt.wildmode = "list:longest"
-- ── Keymaps ───────────────────────────────────────────────────────────────────
-- window navigation
-- window navigation (normal mode)
vim.keymap.set("n", "<C-l>", "<C-w>w")
vim.keymap.set("n", "<C-h>", "<C-w>h")
vim.keymap.set("n", "<C-j>", "<C-w>j")
vim.keymap.set("n", "<C-k>", "<C-w>k")
-- window navigation from terminal-insert mode (exit insert, then move)
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h", { silent = true })
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j", { silent = true })
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k", { silent = true })
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>w", { silent = true })
-- auto-enter insert mode when focusing a terminal buffer (skip floaterm)
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "term://*",
callback = function()
if vim.bo.filetype ~= "floaterm" then
vim.cmd("startinsert")
end
end,
})
-- calendar.vim steals <C-hjkl> for month nav; restore window movement
vim.api.nvim_create_autocmd("FileType", {
pattern = "calendar",