Skip to content

feat(vim): add prompt vim mode with toggle plugin#27616

Closed
m2cci-bouzentm wants to merge 1 commit into
anomalyco:devfrom
m2cci-bouzentm:feature/vim-prompt
Closed

feat(vim): add prompt vim mode with toggle plugin#27616
m2cci-bouzentm wants to merge 1 commit into
anomalyco:devfrom
m2cci-bouzentm:feature/vim-prompt

Conversation

@m2cci-bouzentm
Copy link
Copy Markdown

@m2cci-bouzentm m2cci-bouzentm commented May 14, 2026

Adds Vim-style editing for the TUI prompt behind the existing vim_mode_enabled KV toggle.

The change keeps prompt input behavior isolated in small modules:

  • vim.ts handles dispatch/state transitions.
  • vim-motion.ts handles cursor/range math.
  • vim-keys.ts normalizes terminal key names.
  • vim-types.ts keeps shared prompt Vim types.

Supported behavior includes insert/normal mode, common motions (h/j/k/l, w/b/e, 0/^/$, gg/G), operators (x, d, c), word text objects (iw, aw), find motions (f/t/F/T), and ;/, repeat.

Issue for this PR

N/A

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This adds Claude-Code-inspired Vim prompt editing to the OpenCode TUI prompt. The prompt adapter reads vim_mode_enabled from KV, exposes INSERT/NORMAL status, and delegates Vim key handling to the new prompt Vim modules.

The implementation is split so motion/range logic can be tested without booting the TUI. The prompt adapter only wires TUI state, cursor movement, text replacement, and the toggle.

How did you verify your code works?

  • bun test test/cli/cmd/tui/prompt-vim.test.ts -> 15 pass, 96 assertions.
  • bun run --cwd packages/opencode typecheck -> clean.
  • opencode --version and opencode --help from the patched local launcher -> worked.
  • Real PTY E2E run against local OpenCode -> 31 cases passed, covering motions, operators, text objects, find/repeat, and insert/append commands.

Screenshots / recordings

Not included. This is terminal prompt input behavior; verification is covered by unit tests and PTY E2E.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicates Found

PR #12679: feat(tui): vim motions in prompt input
#12679

Why it might be related: This PR also implements vim motions in the prompt input, which directly overlaps with the current PR #27616's feature set (motions h/j/k/l/w/b/e/0/^/$/gg/G). Both PRs target vim keybinding support in the prompt/TUI. This could be a duplicate or a closely related effort that should be checked for overlap.

Implements insert/normal mode, motions (h/j/k/l/w/b/e/0/^/$/gg/G),
operators (x/d/c), text objects (iw/aw), find (f/t/F/T) with repeat.

- SOLID split: vim.ts dispatch, vim-motion.ts, vim-keys.ts, vim-types.ts
- Regression tests: 15 pass, 96 assertions
- PTY E2E: 31 real terminal cases verified
- Plugin toggle via vim-bindings command + vim_mode_enabled KV
- Pinned to local opencode binary for E2E
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

1 participant