[PR #1774] [CLOSED] feat(tui): vim mode #10057

Closed
opened 2026-02-16 18:14:37 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1774
Author: @lnittman
Created: 8/10/2025
Status: Closed

Base: devHead: vim-mode


📝 Commits (4)

  • df07e51 feat(tui): implement comprehensive vim mode support
  • 7657824 test(vim): add comprehensive test suite for vim mode
  • 99572ea test: add focused tests for vim mode features
  • 496eee1 feat: improve vim mode search and leader key functionality

📊 Changes

20 files changed (+6996 additions, -0 deletions)

View changed files

📝 .gitignore (+1 -0)
CLAUDE.md (+115 -0)
packages/tui/.codex-vim-audit.md (+161 -0)
packages/tui/codex-vim-audit.sh (+126 -0)
packages/tui/coverage.out (+910 -0)
packages/tui/internal/components/vim/coverage_test.go (+238 -0)
packages/tui/internal/components/vim/debug_test.go (+41 -0)
packages/tui/internal/components/vim/factory.go (+193 -0)
packages/tui/internal/components/vim/factory_test.go (+45 -0)
packages/tui/internal/components/vim/mode.go (+386 -0)
packages/tui/internal/components/vim/mode_test.go (+431 -0)
packages/tui/internal/components/vim/motion.go (+812 -0)
packages/tui/internal/components/vim/motion_test.go (+355 -0)
packages/tui/internal/components/vim/parser.go (+685 -0)
packages/tui/internal/components/vim/parser_test.go (+648 -0)
packages/tui/internal/components/vim/search_test.go (+146 -0)
packages/tui/internal/components/vim/test_helpers.go (+77 -0)
packages/tui/internal/components/vim/textarea.go (+1265 -0)
packages/tui/internal/components/vim/visual_indicator.go (+76 -0)
packages/tui/internal/components/vim/visual_indicator_test.go (+285 -0)

📄 Description

summary

this pr adds comprehensive vim mode support to the opencode tui prompt editor, providing a familiar editing experience for vim users.

key features

core vim functionality

  • modal editing with normal, insert, visual, and visual-line modes
  • complete motion engine supporting h/j/k/l, w/b/e, 0/$, gg/G
  • operators: delete (d), change (c), yank (y), paste (p/P)
  • doubled operators for line operations (dd, cc, yy)
  • text objects: inner/around word, quotes, brackets, braces, parentheses
  • character search motions: f/F/t/T with count support
  • proper vim-style search with / and ? commands
  • search navigation with n/N

leader key system

  • configurable leader key (default: space)
  • useful mappings for common operations:
    • <leader>w - save buffer
    • <leader>q - quit vim mode
    • <leader>c - clear prompt
    • <leader>p/P - paste from clipboard
    • <leader>y/d - yank/delete all
    • <leader>v - select all
    • <leader>r - reload config
    • <leader>n/b - next/prev buffer

visual enhancements

  • visual selection highlighting with character/line precision
  • mode indicator in status line
  • selection size display in visual modes
  • pending operator/count display

architectural improvements

  • clean separation of concerns with dedicated vim package
  • factory pattern for switching between regular and vim textareas
  • comprehensive motion engine with text object support
  • robust command parser handling complex vim sequences
  • extensive test coverage for all added functionality

testing

  • comprehensive unit tests for motion engine, parser, and mode manager
  • focused tests specifically for our added features (f/t motions, leader keys, search)
  • integration tests for visual indicators and mode switching
  • all tests passing with proper vim behavior validation

implementation notes

  • maintains backward compatibility with existing textarea functionality
  • vim mode can be toggled on/off without losing content
  • proper handling of edge cases like buffer boundaries
  • efficient implementation with minimal performance impact
  • follows vim conventions for motion inclusivity/exclusivity

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1774 **Author:** [@lnittman](https://github.com/lnittman) **Created:** 8/10/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `vim-mode` --- ### 📝 Commits (4) - [`df07e51`](https://github.com/anomalyco/opencode/commit/df07e5119f69c269d12bd9acf194bdb5cb317b9f) feat(tui): implement comprehensive vim mode support - [`7657824`](https://github.com/anomalyco/opencode/commit/76578244636eae367b41654d3e464287d46a9247) test(vim): add comprehensive test suite for vim mode - [`99572ea`](https://github.com/anomalyco/opencode/commit/99572eafbd41b9be286493dfc6ad0ee42dc1974a) test: add focused tests for vim mode features - [`496eee1`](https://github.com/anomalyco/opencode/commit/496eee104135735bf8ed9c78e63289dec89d86df) feat: improve vim mode search and leader key functionality ### 📊 Changes **20 files changed** (+6996 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) ➕ `CLAUDE.md` (+115 -0) ➕ `packages/tui/.codex-vim-audit.md` (+161 -0) ➕ `packages/tui/codex-vim-audit.sh` (+126 -0) ➕ `packages/tui/coverage.out` (+910 -0) ➕ `packages/tui/internal/components/vim/coverage_test.go` (+238 -0) ➕ `packages/tui/internal/components/vim/debug_test.go` (+41 -0) ➕ `packages/tui/internal/components/vim/factory.go` (+193 -0) ➕ `packages/tui/internal/components/vim/factory_test.go` (+45 -0) ➕ `packages/tui/internal/components/vim/mode.go` (+386 -0) ➕ `packages/tui/internal/components/vim/mode_test.go` (+431 -0) ➕ `packages/tui/internal/components/vim/motion.go` (+812 -0) ➕ `packages/tui/internal/components/vim/motion_test.go` (+355 -0) ➕ `packages/tui/internal/components/vim/parser.go` (+685 -0) ➕ `packages/tui/internal/components/vim/parser_test.go` (+648 -0) ➕ `packages/tui/internal/components/vim/search_test.go` (+146 -0) ➕ `packages/tui/internal/components/vim/test_helpers.go` (+77 -0) ➕ `packages/tui/internal/components/vim/textarea.go` (+1265 -0) ➕ `packages/tui/internal/components/vim/visual_indicator.go` (+76 -0) ➕ `packages/tui/internal/components/vim/visual_indicator_test.go` (+285 -0) </details> ### 📄 Description ## summary this pr adds comprehensive vim mode support to the opencode tui prompt editor, providing a familiar editing experience for vim users. ## key features ### core vim functionality - modal editing with normal, insert, visual, and visual-line modes - complete motion engine supporting h/j/k/l, w/b/e, 0/$, gg/G - operators: delete (d), change (c), yank (y), paste (p/P) - doubled operators for line operations (dd, cc, yy) - text objects: inner/around word, quotes, brackets, braces, parentheses - character search motions: f/F/t/T with count support - proper vim-style search with / and ? commands - search navigation with n/N ### leader key system - configurable leader key (default: space) - useful mappings for common operations: - `<leader>w` - save buffer - `<leader>q` - quit vim mode - `<leader>c` - clear prompt - `<leader>p/P` - paste from clipboard - `<leader>y/d` - yank/delete all - `<leader>v` - select all - `<leader>r` - reload config - `<leader>n/b` - next/prev buffer ### visual enhancements - visual selection highlighting with character/line precision - mode indicator in status line - selection size display in visual modes - pending operator/count display ### architectural improvements - clean separation of concerns with dedicated vim package - factory pattern for switching between regular and vim textareas - comprehensive motion engine with text object support - robust command parser handling complex vim sequences - extensive test coverage for all added functionality ## testing - comprehensive unit tests for motion engine, parser, and mode manager - focused tests specifically for our added features (f/t motions, leader keys, search) - integration tests for visual indicators and mode switching - all tests passing with proper vim behavior validation ## implementation notes - maintains backward compatibility with existing textarea functionality - vim mode can be toggled on/off without losing content - proper handling of edge cases like buffer boundaries - efficient implementation with minimal performance impact - follows vim conventions for motion inclusivity/exclusivity --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:37 -05:00
yindo closed this issue 2026-02-16 18:14:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10057