Skip to content

fix(shell-plugin): add vi-command mode bindings for zsh-vi-mode compatibility#2684

Open
i010542 wants to merge 1 commit intoantinomyhq:mainfrom
i010542:fix/forge-zsh-vi-mode-2681
Open

fix(shell-plugin): add vi-command mode bindings for zsh-vi-mode compatibility#2684
i010542 wants to merge 1 commit intoantinomyhq:mainfrom
i010542:fix/forge-zsh-vi-mode-2681

Conversation

@i010542
Copy link

@i010542 i010542 commented Mar 24, 2026

Problem Summary

When the zsh-vi-mode plugin (from Oh-My-Zsh) is active, none of the forge colon commands work (e.g., :model, :info, :doctor). Users report zsh: command not found: :model even though forge zsh doctor reports all checks passing.

Root Cause

shell-plugin/lib/bindings.zsh sets bindkey '^M' forge-accept-line, but this only binds in the current keymap. In vi-command mode (vicmd), Enter is bound to vi-accept-line, not forge-accept-line. Since forge's colon-command detection lives entirely in forge-accept-line, commands are silently discarded.

Solution

Detect zsh-vi-mode (via $ZVM_MODE variable or bindkey -lL main inspection) and also bind Enter and Tab in vicmd mode to forge's widgets:

if [[ -n "$ZVM_MODE" ]] || bindkey -lL main 2>/dev/null | grep -q "..."; then
    bindkey -M vicmd '^M' forge-accept-line
    bindkey -M vicmd '^J' forge-accept-line
    bindkey -M vicmd '^I' forge-completion
fi

This is non-breaking: the check only activates when vi mode is detected.

Test Evidence

  1. Load forge plugin with zsh-vi-mode enabled in ~/.zshrc:
    plugins=(zsh-vi-mode)
  2. Type :model and press Enter → should invoke forge-accept-line
  3. Tab completion → should invoke forge-completion

Key Differentiator

Unlike a generic "add vi mode support" patch, this specifically targets the zsh-vi-mode plugin's keymap isolation — a narrow, well-scoped fix for the reported bug.


Resolves: #2681

…tibility

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#2681
Co-Authored-By: ForgeCode <noreply@forgecode.dev>
@i010542
Copy link
Author

i010542 commented Mar 24, 2026

Hi @tusharmath — PR #2684 ready for review! Fixes issue #2681: zsh-vi-mode compatibility for forge colon commands.

What changed: now also binds Enter and Tab in vicmd mode when zsh-vi-mode is detected.

Root cause: "^M" accept-line only sets the binding in the current keymap. In vicmd mode, Enter was bound to vi-accept-line, bypassing forge-accept-line entirely.

Test: Load zsh-vi-mode in ~/.zshrc, type :model, press Enter — should work now.

Happy to refine based on your feedback! 🙏

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: incompatible with zsh-vi-mode zsh plugin (OMZ)

2 participants