Skip to content

Toggle vim - Creates an Opencode command that toggles the VimMode off/on for this session.#29

Merged
oribarilan merged 6 commits into
oribarilan:mainfrom
S-andres0694:toggle-vim
Jun 11, 2026
Merged

Toggle vim - Creates an Opencode command that toggles the VimMode off/on for this session.#29
oribarilan merged 6 commits into
oribarilan:mainfrom
S-andres0694:toggle-vim

Conversation

@S-andres0694

Copy link
Copy Markdown
Contributor

Add ‎/vim toggle command 

Adds a runtime toggle to enable/disable vim mode without restarting OpenCode.

How it works?

Typing ‎/vim in the command palette flips ‎state.disabled. When disabled, the key intercept returns early before any vim processing, so all keys pass through to OpenCode as if the plugin weren’t loaded. The state is persisted via ‎api.kv so the preference survives restarts.

Closes #4

…hrough vim-motions

- Implemented a toggle for VimMode using opencode commands.
@S-andres0694

Copy link
Copy Markdown
Contributor Author

Just want to confirm that at the moment, I have not tested this because the just dev workflow does not overwrite the configuration of my plugins and it keeps using the latest configuration, which does not have my changes.

I have tried overwriting the opencode.json to use the directory containing the codebase but it did not work either. I'll update.

@S-andres0694

Copy link
Copy Markdown
Contributor Author

It seems that there are issues when trying to replace the tui.json as it seems to be merging it with the one in .config/opencode/tui.json. Fix was to temporarily rename it such that the merging would not happen. Should work perfectly now! @oribarilan

@oribarilan oribarilan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this contribution! please see my comments

Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/vim.ts
Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment thread CHANGELOG.md
@S-andres0694

Copy link
Copy Markdown
Contributor Author

Tried to address all of the feedback!

@S-andres0694 S-andres0694 requested a review from oribarilan June 9, 2026 13:44
@oribarilan oribarilan merged commit d1dc013 into oribarilan:main Jun 11, 2026
1 check passed
@S-andres0694 S-andres0694 deleted the toggle-vim branch June 11, 2026 07:56
oribarilan pushed a commit that referenced this pull request Jun 12, 2026
….keymap.registerLayer` (#34)

Moves ‎`:q`, ‎`:quit`, and ‎`:wq` to the ‎`registerLayer` API,
consolidating them with the existing ‎`/vim` toggle command into a
single ‎`registerLayer` call. This was decoupled from #29 during review
to keep that PR focused on the toggle feature.

Changes:

- Replaced ‎`api.command?.register` with ‎`api.keymap.registerLayer` for
all three quit commands

- Added ‎`slashName` so they’re accessible as slash commands

- Removed the now-unused ‎`api.command?.register` call

Closes #33
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.

command to toggle vim mode on/off

2 participants