Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Contributing

Bug reports, fixes, and improvements are welcome.

## Reporting bugs

Include the OpenCode and plugin versions, your operating system and terminal,
and steps to reproduce the problem. Mention the Vim mode, relevant custom
keybindings, and whether you use a terminal multiplexer such as tmux. Describe
what you expected and what happened instead.

For larger changes, open an issue first so we can agree on the approach.

## Development setup

Fork and clone the repository, then create a branch based on `dev`.
Use Node.js 22 (the CI version), npm, and a current version of Bun.

```sh
npm ci
```

The test helpers support Linux and macOS on x64 and ARM64. E2E tests also require
tmux. Downloads use `tar`, plus `unzip` on macOS.

## Running tests

```sh
bun run typecheck
bun run test
bun run test:e2e
```

- `test` covers editing behavior, plugin integration, source and npm package
loading, and comparisons against a pinned Neovim version downloaded
automatically.
- `test:e2e` builds and packs the current plugin, then runs real terminal
interactions against the latest stable OpenCode 2 release. Each scenario gets
isolated configuration and a fresh session, with imported fixture transcripts
for message-reader and history tests. No model requests are submitted.
Captures, logs, and results are saved under `test-results/e2e/`.

Run individual scenarios with `bun run test:e2e message-reader`.

Internet access is needed for initial binary downloads and for E2E tests to
resolve the latest OpenCode release. Downloaded binaries are cached under
`node_modules/.cache/`.

Use `bun run build` to build the plugin into `dist/`.

## Adding tests

Put unit tests in `test/unit/`, integration tests in `test/integration/`, and
shared fixtures and setup in `test/helpers/`.

Add focused regression coverage for bug fixes. Use E2E scenarios when the behavior
depends on real OpenCode keyboard handling, focus, dialogs, or tabs.

E2E scenarios live in `test/e2e/scenarios/` and are registered in
`test/e2e/run.ts`. Reuse the shared fixture and terminal helpers, and wait for
expected screen content rather than using fixed delays.

## Pull requests

- Target `dev`.
- Follow the surrounding code style and favor straightforward, readable code.
- Keep PRs focused and descriptions short, clear, and to the point. Explain what
changed, why, and how you tested it. Respect reviewers' time: avoid walls of
text, repetitive summaries, and unnecessary detail. Link related issues.
- If you use AI, understand, review, and test the changes before submitting.
You are responsible for everything in your PR.

## License

Contributions are licensed under the project's [MIT License](LICENSE).
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Tarquinen and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 4 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ All options below belong inside `options.vim`.
| --- | --- | --- |
| `defaultMode` | `"insert"` | Starting Vim mode; use `"normal"` to start in normal mode |
| `sessionKey` | `"s"` | Single key to enter and leave session mode |
| `diffView` | `"after"` | Starting edit/patch view: `"after"`, `"before"`, or `"diff"`; added/deleted files use the available side |
| `keymapTimeout` | `500` | Milliseconds to wait for the rest of a custom mapping |
| `keymaps` | `{}` | Prompt and search-dialog mappings, grouped by mode |
| `keymaps` | `{}` | Custom mappings, grouped by mode |
| `cursorStyles` | See below | Cursor appearance for each editing mode |
| `debug` | `false` | Enable debug logging |
| `debugPath` | `~/.cache/opencode/opencode-vim.log` | Debug log file |
Expand All @@ -47,8 +48,8 @@ entering session mode.
### Custom keymaps

Mappings apply to `insert`, `normal`, `visual`, and `visual-line` editing modes in
the prompt and search dialogs. Session browsing and its read-only modal use their
own bindings.
the prompt and search dialogs. Use `keymaps.session` for transcript browsing and
its message/tool modals.

See [Custom Keymaps](./keymap-actions.md) for actions, key notation, and examples.
See [Keybindings and Modes](./vim-behavior.md) for the default behavior.
Expand Down
16 changes: 13 additions & 3 deletions docs/keymap-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Each entry maps a key sequence to an action in one Vim mode. Put `keymaps` insid
"H": "0",
"L": "$",
"q": "command:session.new"
},
"session": {
"<Tab>": "passthrough",
"<C-w>w": "switch-panel"
}
}
}
Expand All @@ -23,8 +27,8 @@ Each entry maps a key sequence to an action in one Vim mode. Put `keymaps` insid
## Modes and actions

Mappings apply while editing the prompt or a search dialog, in `insert`, `normal`,
`visual`, or `visual-line` mode. They do not replace session-browsing or reader
bindings; use `sessionKey` to change the session toggle.
`visual`, or `visual-line` mode. `session` mappings apply to transcript browsing
and its message/tool modals; use `sessionKey` to change the session toggle.

| Action | Behavior |
| --- | --- |
Expand All @@ -33,13 +37,19 @@ bindings; use `sessionKey` to change the session toggle.
| `submit` | Submit the prompt or confirm the search dialog |
| `command:<id>` | Dispatch an active OpenCode command |
| Vim key sequence, such as `y$` | Run those Vim keys |
| `switch-panel` | Session only: switch between available panels |
| `passthrough` | Session only: leave a single key to OpenCode without consuming it |

Insert-mode mappings support only `normal`, `submit`, `command:<id>`, or Escape
(`"<Esc>"` / `"<C-[>"`). Other editing modes support all action types above.
(`"<Esc>"` / `"<C-[>"`). Other editing modes support all editing actions above.

Mapping sequences are literal: mapping `j` to `j` uses an actual line, while
mapping it to `gj` uses a wrapped row.

Session mappings override defaults: `<Tab>` switches panels where available.
The example above releases Tab to OpenCode and uses Ctrl+W then w to switch panels.
Native commands still depend on the current UI context.

## Key notation

Use printable ASCII characters; uppercase letters represent shifted keys. Use
Expand Down
8 changes: 5 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "opencode-vim",
"version": "0.0.26",
"version": "0.0.27",
"license": "MIT",
"type": "module",
"repository": {
"type": "git",
Expand All @@ -14,12 +15,13 @@
"build": "bun scripts/build.ts",
"prepack": "bun run build",
"typecheck": "tsc --noEmit",
"test": "bun test --conditions=browser --preload @opentui/solid/preload",
"test": "bun test --conditions=browser --preload @opentui/solid/preload ./test/unit ./test/integration",
"test:e2e": "bun test/e2e/run.ts",
"bench": "bun test/benchmark.ts"
},
"dependencies": {
"@vimee/core": "^0.3.0"
"@vimee/core": "^0.3.0",
"diff": "^9.0.0"
},
"peerDependencies": {
"@opencode/plugin": "2.0.10",
Expand Down
17 changes: 0 additions & 17 deletions src/modules/snippets/index.tsx

This file was deleted.

147 changes: 0 additions & 147 deletions src/modules/snippets/loader.ts

This file was deleted.

Loading
Loading