Skip to content

Add dot repeat, safer undo, leader passthrough, and V selection#22

Closed
hamidi-dev wants to merge 2 commits into
oribarilan:mainfrom
hamidi-dev:main
Closed

Add dot repeat, safer undo, leader passthrough, and V selection#22
hamidi-dev wants to merge 2 commits into
oribarilan:mainfrom
hamidi-dev:main

Conversation

@hamidi-dev

@hamidi-dev hamidi-dev commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add normal-mode . repeat for command-based changes like dw, dd, x, and r{char}
  • Store vim change undo snapshots on a stack so repeated/count-based changes can be undone cleanly
  • Pass through OpenCode leader sequences in normal/visual mode, including configured leaders and Tab
  • Add V to select the current line and enter visual mode

Fixed

  • dw.. now repeats the delete-word change
  • u after dw.. walks back each repeated delete
  • 3dw now restores in one undo step
  • OpenCode leader bindings like <leader>e, <leader>l, and <leader>n are no longer swallowed by vimcode

Testing

  • bun test
  • bunx biome ci --error-on-warnings .

@hamidi-dev hamidi-dev marked this pull request as draft June 5, 2026 11:58
@hamidi-dev hamidi-dev changed the title fix: add dot repeat and prefix passthrough Add dot repeat, safer undo, leader passthrough, and V selection Jun 5, 2026
@hamidi-dev hamidi-dev marked this pull request as ready for review June 5, 2026 17:13
@oribarilan

Copy link
Copy Markdown
Owner

hey @hamidi-dev thx for the contribution. I prefer each PR to address a single specific issue, to allow easy rollback and troubleshooting. If possible, please split and send whatever you want out of this, and I will review and approve. Thanks!

@samuelmasuy

samuelmasuy commented Jun 10, 2026

Copy link
Copy Markdown

I'm really looking forward for "Pass through OpenCode leader" feature/fix. If I can help, let me know. Right now, it's akin to tmux prefix would not work in vim normal mode.

@oribarilan

Copy link
Copy Markdown
Owner

@samuelmasuy it is already supported a few versions back :) please see
#21

LMK if you like it or find something missing please (you can reuse issue 21 or open a new one)

@hamidi-dev

Copy link
Copy Markdown
Contributor Author

@oribarilan @samuelmasuy sorry i haven't gotten the time yet to address @oribarilan requests.
if the prefix issue is solved, thats great. i will work on the other topics of my PR.
or do you have an issue @samuelmasuy with prefix?
my original issue was using TAB as prefix.
I would have to test the v0.11.0 and see if that solves the TAB as prefix issue.

@samuelmasuy

samuelmasuy commented Jun 10, 2026

Copy link
Copy Markdown

@samuelmasuy it is already supported a few versions back :) please see #21

LMK if you like it or find something missing please (you can reuse issue 21 or open a new one)

I should have been more precise: this is not working for me, unless I configured something incorrectly.
My leader in opencode is <C-x>, and I have the plugin configured like this:

[
  "vimcode@git+https://github.com/oribarilan/vimcode.git#v0.13.0",
  {
    "modeToast": false,
    "startMode": "normal",
    "leader": "C-x",
  },
]

When I’m in normal mode and press C-x-m (to list models), the m gets swallowed.
On this branch, though, the leader works from any mode, which is how I expected it to behave.

@oribarilan

Copy link
Copy Markdown
Owner

@samuelmasuy vimcode doesn't require you to configure it, it uses the leader key you already have configured.
It wasn't documented well so I added this section, you can read it and see how it goes now :)

https://github.com/oribarilan/vimcode#leader-key

@samuelmasuy

samuelmasuy commented Jun 12, 2026

Copy link
Copy Markdown

@samuelmasuy vimcode doesn't require you to configure it, it uses the leader key you already have configured. It wasn't documented well so I added this section, you can read it and see how it goes now :)

https://github.com/oribarilan/vimcode#leader-key

I tried that too, here is a simple tui.json that reproduces for me:

{
  "$schema": "https://opencode.ai/tui.json",
  "keybinds": {
    "leader": "ctrl+x"
  },
  "plugin": [
    [
      "vimcode@git+https://github.com/oribarilan/vimcode.git#v0.13.0",
      {
        "modeToast": false,
        "startMode": "normal"
      }
    ]
  ]
}

<ctrl+x>m in normal mode does not popup the model selection. Note that not specifying any keybinds ALSO reproduces.

oribarilan added a commit that referenced this pull request Jun 13, 2026
Fixes leader key being broken for any config with modifiers, including
the default `ctrl+x`.

`parseLeaderKey("ctrl+x")` expected vim-style `C-x` notation but
OpenCode returns `ctrl+x` format. The parser never recognized the
modifiers, so every match failed silently.

Fix: drop the format translation. New `src/leader.ts` matches against
OpenCode's native `KeyLike` type directly, with modifier alias support
(`control`, `alt`, `option`) and case normalization. Removes
`ParsedLeader`/`parseLeaderKey`/`matchesLeader` from `vim.ts`.

Ref: #22
@oribarilan

Copy link
Copy Markdown
Owner

@samuelmasuy thanks! i found the issue, i pesonally use non-modifier leaders since vimcode, but the issue was the mismatch between opencode and vim modifier syntax.

can you please re-evaluate?

#37

@hamidi-dev i would love you to take either of the 3 changes (dot repeat, undo, V selection) if you want to pursue them, but not combined, so i can more easily review and roll-back as needed.

@hamidi-dev

Copy link
Copy Markdown
Contributor Author

@oribarilan the PR for V selection is open...

@samuelmasuy

Copy link
Copy Markdown

@samuelmasuy thanks! i found the issue, i pesonally use non-modifier leaders since vimcode, but the issue was the mismatch between opencode and vim modifier syntax.

can you please re-evaluate?

#37

Using 0.14.0, it fixes the leader in normal mode, but it breaks it in insert mode.

@oribarilan

Copy link
Copy Markdown
Owner

Can you explain what it means "breaks"? In insert mode, leader key is expected to
(1) be written if leader is printable (eg space)
Or (2) be swallowed if not printable (eg ctrl-x)

What are you experiencing?

@samuelmasuy

Copy link
Copy Markdown

Can you explain what it means "breaks"? In insert mode, leader key is expected to
(1) be written if leader is printable (eg space)
Or (2) be swallowed if not printable (eg ctrl-x)

What are you experiencing?

Assuming my leader is <crtl+x> I would expect <ctrl+x>m to show me the list of models in ANY mode. Using 0.14 that does not work in insert mode.
Note that using the current pr, I get the expected behaviour.

@oribarilan

Copy link
Copy Markdown
Owner

@samuelmasuy in vim , leader is a normal mode thing, won't work in insert, this is why it is implemented as such.
i do agree that it can be great to add non-printable leader support in insert. i will create an issue and support it. it is a very small change, i just want to test it out and see before i merge. thanks!

@oribarilan

oribarilan commented Jun 16, 2026

Copy link
Copy Markdown
Owner

@samuelmasuy #45 :) will be available in upcoming release. Thanks for the inputs!

@samuelmasuy

Copy link
Copy Markdown

@samuelmasuy #45 :) will be available in upcoming release. Thanks for the inputs!

Thank you very much it works as expected. ❤️

@oribarilan

Copy link
Copy Markdown
Owner

@hamidi-dev i think the dot repeat is the only part left, if you wish to open an issue and/or a dedicated PR for that. Closing this one for now.
Thanks!

@oribarilan oribarilan closed this Jun 22, 2026
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.

3 participants