opencode.nvim: a Neovim integration for OpenCode AI that enables context-aware pairing and side-by-side edit reviews
opencode.nvim: a Neovim integration for OpenCode AI that enables context-aware pairing and side-by-side edit reviews
What it solves
It integrates the OpenCode AI pairing tool into Neovim, allowing developers to access AI-assisted coding without leaving their editor. It focuses on a "pair programmer" model where the human remains in control of the code while the AI provides context-aware suggestions and edits.
How it works
The plugin connects to an OpenCode server (either local or remote) via an API. It allows users to inject editor context—such as the current selection, buffer, or diagnostics—into prompts using placeholders like @this or @buffer. It supports executing commands to manage AI sessions, handling server-sent events, and managing AI-proposed edits through a side-by-side diff view using Neovim's :diffpatch.
Who it’s for
Neovim users who want to integrate AI coding assistance into their existing workflow and configuration without switching to a separate AI-centric IDE.
Highlights
- Context Injection: Automatically provides the AI with the current cursor position, open buffers, and diagnostics.
- Integrated Edit Management: Proposed changes are presented as a diff, allowing users to accept or reject specific hunks of code.
- TUI Integration: Leverages OpenCode's existing TUI and API for a seamless experience.
- Customizable Prompts: Includes built-in prompts for reviewing, documenting, and optimizing code.
- Extensible: Supports integration with other Neovim plugins like
snacks.nvimandblink.cmpfor enhanced input and completion.
Sources
- undefinednickjvandyke/opencode.nvim