Commit Graph

17 Commits

Author SHA1 Message Date
QQ 628f8250f8 fix: guard original_bufnr validity on borrowed restore
If the user deletes the original empty buffer (:bw!) between
hide and restore, nvim_win_set_buf would error. Now falls back
to closing the window if the original buffer is invalid.
2026-06-17 16:36:24 +08:00
QQ 25ea356161 refactor: dynamic keymap registration from config.commands
Replace hardcoded reasonix/lazygit keymap blocks with a single
loop over config.commands. Adding a new tool (e.g. codex) now only
requires two lines in user config:

  commands = { codex = 'codex' },
  keymaps  = { codex = { 'n', '<leader>cx' } },

Commands can be strings or functions for lazy evaluation.
2026-06-17 15:44:16 +08:00
QQ 718ce9036f fix: detect buffer mismatch on toggle (e.g. :e opened file over terminal)
When terminal occupies main window and user directly opens a file
(:e somefile) in that window, the window's buffer no longer matches
term.bufnr. Previously this caused the hide path to incorrectly swap
back original_bufnr, wiping the user's file. Now we detect mismatch,
clear winid/borrowed, and re-evaluate use_main — which will correctly
fall through to a split when a real file is present.
2026-06-17 15:21:53 +08:00
QQ 81d623c5c0 feat: occupy main window when no file is open
When Neovim is launched without a file (empty unnamed buffer),
QQdock now reuses the current window instead of creating a split.
Toggle hide swaps back to the original empty buffer.

Detection: buffer name is empty, buftype empty, not modified.
Cache tracks borrowed flag and original_bufnr for restore.
2026-06-17 15:17:01 +08:00
QQ ae1d2146c6 fix: replace toggleterm split with native rightbelow terminal
Root cause: toggleterm uses botright split (tabpage-level) and
find_open_windows() jumps to existing terminals across tabpages,
destroying window layouts. persist_size=false in Terminal opts was
never consumed by toggleterm's ui.get_size().

Changes:
- Replace toggleterm Terminal cache with own {bufnr, winid, job_id, cmd}
- Use rightbelow {size}split/vsplit (current-window-local)
- Three-path open: hide (close win), restore (assign buf to new split), create
- winfixwidth/winfixheight to protect terminal window size
- bufhidden=hide to keep process alive on window close
- <C-\><C-\> hide keymap on terminal buffers
- config.debug flag for layout diagnostics
- pcall toggleterm setup(persist_size=false) as safety net
2026-06-17 15:10:34 +08:00
QQ a3dfc7e01c update 2026-06-17 15:01:48 +08:00
QQ 0f036b6b58 feat: configurable keymaps + commands, README with examples 2026-06-11 21:13:58 +08:00
QQ a169b3139c fix: <C-\><C-\> toggles in ALL terminals, no Esc override needed 2026-06-11 21:07:21 +08:00
QQ a26dc1a51a fix: only bind Esc→normal in shell, not TUI programs (Reasonix/lazygit) 2026-06-11 21:01:03 +08:00
QQ 23984f2756 fix: map <Esc> to <C-\><C-n> in terminal buffers so Esc exits to normal mode 2026-06-11 20:56:56 +08:00
QQ 977384ccda fix: Terminal hidden=true — keep process alive across toggle 2026-06-11 20:53:27 +08:00
QQ bf7bd9fe42 fix: reuse terminal instance after hide (is_open returns false on toggle) 2026-06-11 20:09:25 +08:00
QQ 898ab9caaa feat: expose size config via M.setup({size={horizontal,vertical}}) 2026-06-11 20:00:05 +08:00
QQ 8981eebd1a fix: remove custom size, use toggleterm defaults 2026-06-11 19:55:09 +08:00
QQ 2611de78f2 init: QQdock.nvim — persistent adaptive terminal dock 2026-06-11 19:16:35 +08:00
mathew ab9a28a3e1 improve script and add example codes 2023-06-18 14:38:43 +08:00
mathew df1565e80c update 2023-06-16 16:10:41 +08:00