From 458239e5aeb0e7f0d0a43232e8080ebd27a01d4c Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Tue, 24 Mar 2026 20:02:06 +0800 Subject: [PATCH] fix(shell-plugin): add vi-command mode bindings for zsh-vi-mode compatibility When the zsh-vi-mode plugin (jeffreytse/zsh-vi-mode) is active, the Enter key in vi-command mode does not trigger forge's colon commands. Users report 'command not found: :model' and similar errors. Root cause: bindkey '^M' only sets the binding in the current keymap. In vicmd mode, Enter is bound to vi-accept-line, not forge-accept-line. Fix: also bind Enter and Tab in vicmd mode when zsh-vi-mode is detected. Detection uses $ZVM_MODE (zsh-vi-mode plugin) or bindkey -lL main (native vi mode via bindkey -v). Fixes: antinomyhq/forgecode#2681 Co-Authored-By: ForgeCode --- shell-plugin/lib/bindings.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/shell-plugin/lib/bindings.zsh b/shell-plugin/lib/bindings.zsh index 5100f3fb5b..82bfc9b6f8 100644 --- a/shell-plugin/lib/bindings.zsh +++ b/shell-plugin/lib/bindings.zsh @@ -29,3 +29,14 @@ bindkey '^M' forge-accept-line bindkey '^J' forge-accept-line # Update the Tab binding to use the new completion widget bindkey '^I' forge-completion # Tab for both @ and :command completion + +# Fix: zsh-vi-mode plugin compatibility +# When zsh-vi-mode (jeffreytse/zsh-vi-mode) is active, Enter in vi-command mode +# does not trigger forge's colon commands. Fix by also binding Enter in vicmd. +# Detects both zsh-vi-mode plugin ($ZVM_MODE) and native vi mode (bindkey -v). +if [[ -n "$ZVM_MODE" ]] || bindkey -lL main 2>/dev/null | grep -q "bindkey -A viins main\|bindkey -A vicmd main"; then + bindkey -M vicmd '^M' forge-accept-line + bindkey -M vicmd '^J' forge-accept-line + # Also bind Tab in vicmd for @ and :command completion + bindkey -M vicmd '^I' forge-completion +fi