opencode.nvim
Connect Neovim to OpenCode within your existing editor workflow.
Evidence shows the plugin asks user approval for permission requests (user_confirmation=2), but least privilege is not explicitly addressed (least_privilege=1). Data flow transparency is limited; no detailed explanation of what data is sent to OpenCode server (data_flow_transparency=1). Sensitive data handling not specified (sensitive_data_handling=1). Dependency security not assessed, relies on external tools (dependency_security=1). External effects limited but not detailed (external_effects=1). Rollback mechanism not specified (rollback=1). Source attribution via README and license, but publisher unverified (source_attribution=1).
Self-consistency is good; documentation and code examples align (self_consistency=2). Dependency availability not explicitly stated, relies on external OpenCode and Neovim (dependency_availability=1). Failure messages not detailed (failure_messages=1).
Target audience clear (Neovim users), scenarios well-defined (audience_and_scenarios=2). Capability boundaries clear, e.g., single OpenCode instance (capability_boundaries=2). Trigger precision high via commands and keymaps (trigger_precision=2). Environment fit good with multiple installation methods (environment_fit=2).
Information architecture clear, well-structured docs (information_architecture=2). Install notes detailed (install_notes=2). Naming stable, consistent API (naming_stability=2). Examples and FAQ sufficient (examples_and_faq=2). Known limitations mentioned but sparse (known_limitations=1). License clear MIT (license=2). Versioning and changelog not explicit (versioning_changelog=1). Maintenance responsibility not clear (maintenance_responsibility=1).
Output usability high with multiple interaction modes (output_usability=2). Marginal value clear, integrates existing tools (marginal_value=2). Cost-benefit reasonable, free and open source (cost_benefit=2).
Claim traceability moderate; some features not detailed (claim_traceability=1). Cross-source corroboration limited, relies on single repo (cross_source_corroboration=1). Fact-inference separation not explicit (fact_inference_separation=1).
- Publisher identity unverified; use with caution.
- Permission handling details limited; review code for least privilege.
- Data flow transparency insufficient; understand what data is sent to OpenCode server.
- Relies on external OpenCode and Neovim; ensure environment compatibility.
What does this agent do, and when should you use it?
opencode.nvim is a Neovim plugin that integrates with OpenCode's TUI and server to bring AI pair programming into the standard Neovim interface. It enables injecting editor context (cursor, selection, buffers) into prompts, supports prompt input with completions and highlighting, selection from built-in or custom prompts, execution of OpenCode commands, accepting/rejecting/reloading edits, and handling OpenCode events as autocmds. The plugin can connect to any OpenCode server or start an integrated instance. It prioritizes focused pairing with a single OpenCode instance and provides simple, Vim-centric defaults. Setup is straightforward via vim.pack, lazy.nvim, or nixvim.
opencode.nvim exposes a Lua API via require("opencode"), including ask() for prompting, select() for choosing prompts/commands/servers, prompt() for sending prompts with context injection, operator() for operator-style usage, and command() for executing OpenCode commands like session.new or session.undo. It replaces context placeholders (@this, @buffer, @diagnostics) in prompts. When OpenCode edits a file, the plugin reloads the buffer and shows the diff using Neovim's :diffpatch for review. It also forwards Server-Sent Events as OpencodeEvent autocmds for custom handling. Server discovery and startup are controlled via vim.g.opencode_opts.server, defaulting to starting term://opencode --port. Permissions requests trigger interactive approval dialogs.
- Neovim users who want to leverage OpenCode without leaving their editor.
- Developing features that benefit from sending specific code regions or buffers as context for AI suggestions.
- Teams that want to standardize AI prompts (e.g., code review, testing) across their editor setup.
- Power users who need to automate or react to OpenCode session events, such as status updates or permission requests.
- Developers who prefer to review and accept AI-generated edits using familiar diff tools within Neovim.
What are this agent's strengths and limitations?
- Deep integration with Neovim using native interfaces (diff, operators, autocmds).
- Preserves existing editor muscle memory and workflow, no new interaction model.
- Flexible server configuration: connect to any OpenCode server or auto-start one.
- Context injection and built-in prompt library accelerate common tasks (review, test, etc.).
- Event-driven architecture enables real-time updates and custom automations.
- Requires OpenCode CLI installed and configured to expose its server on a port.
- Designed primarily for single-instance use; switching between servers frequently may need
connectadjustments. - Written in Lua; users unfamiliar with Neovim plugin development may find customization challenging.
- Depends on OpenCode's API and event formats; version mismatches could break functionality.
- Limited documentation on extending the plugin beyond provided options; advanced use may require reading type definitions.
How do you install or deploy this agent?
Recommended: use vim.pack by adding vim.pack.add({ { src = "https://github.com/nickjvandyke/opencode.nvim", version = vim.version.range("*") } }) and set vim.g.opencode_opts. Alternative: lazy.nvim with { "nickjvandyke/opencode.nvim", version = "*", config = function() ... end }, or nixvim with extraPlugins = [ pkgs.vimPlugins.opencode-nvim ];. After installation, run :checkhealth opencode.
How do you use this agent?
Ensure OpenCode CLI is installed and can be run (with --port flag). Configure vim.g.opencode_opts and define keymaps, for example: vim.keymap.set({ "n", "x" }, "<C-a>", function() require("opencode").ask("@this: ") end). Then use the keymaps to invoke ask/select/operator. The plugin will attempt to connect to a running OpenCode server, or start one via the server.start function. Optionally, set server.url to connect to a remote server.
FAQ
How do I connect to a remote OpenCode server?
vim.g.opencode_opts.server.url to the server's URL (e.g., http://localhost:PORT or a remote address). The plugin will connect to that server instead of starting a new one.How are edit permissions handled?
:diffpatch to show changes. You can press da to accept all, dr to reject all, or dp/do to accept/reject the hunk under the cursor.Which context placeholders are available?
@this (range/selection or cursor position), @buffer (current buffer), @buffers (all open buffers), @diagnostics, @marks, @quickfix, and @visible.Can I customize the built-in prompts?
lua/opencode/config.lua.Does it support multiple OpenCode instances simultaneously?
vim.g.opencode_opts.server.connect to avoid disruptive synchronous events.