Skip to content

Code Preview.Nvim

A Neovim plugin that shows a live diff preview of AI coding agent's file edits before you accept or reject them.

Install

$git clone https://github.com/Cannon07/code-preview.nvim

Install command taken from the project's README or registry entry. Always review code before running it.

code-preview.nvim

Review every edit your AI coding agent makes as a native Neovim diff — before it's written to disk.

Works with Claude Code, OpenCode, GitHub Copilot CLI, and OpenAI Codex CLI — on macOS, Linux, and Windows.


Demo

Shown with Claude Code. OpenCode, GitHub Copilot CLI, and Codex CLI work the same way — expand 📺 More demos below.


Why

Your AI coding agent proposes edits in its terminal — a cramped, scroll-past diff you have to eyeball before typing y. code-preview.nvim intercepts that moment and opens the proposed change as a real Neovim diff: full syntax highlighting, your colorscheme, your keymaps. Review it like any other diff, then accept or reject in the agent's CLI as usual.

  • 🔍 See edits as native diffs — side-by-side or GitHub-style inline, before anything touches disk
  • 🤝 Agent-agnostic — Claude Code, OpenCode, Copilot CLI, Codex CLI, with more agents planned
  • 🌳 Neo-tree integration — your file tree marks what's being modified, created, or deleted
  • 🪶 No Python — file transforms run through nvim --headless -l; the only hard dep is Neovim 0.10+

📺 More demos

OpenCode

GitHub Copilot CLI

OpenAI Codex CLI

Neo-tree integration


Install

With lazy.nvim:

{
  "Cannon07/code-preview.nvim",
  config = function()
    require("code-preview").setup()
  end,
}

Manual (path-based)

vim.opt.rtp:prepend("/path/to/code-preview.nvim")
require("code-preview").setup()

Requirements: Neovim >= 0.10. Each agent has a couple of extra needs — see below.

Per-agent requirements

Agent Needs
Claude Code Claude Code CLI (with hooks) · jq
OpenCode OpenCode (a version with plugin support)
GitHub Copilot CLI Copilot CLI (GA since Feb 2026)
OpenAI Codex CLI Codex CLI recent enough for apply_patch PreToolUse hooks · jq

On Windows, the Copilot CLI hook runs under PowerShell 7+ and needs no jq.


Quick start

After setup(), the flow is the same for every agent:

  1. Open your project in Neovim.
  2. Install the agent's hooks (one command — pick your agent below) and restart that agent's CLI.
  3. Ask the agent to edit a file — a diff preview opens automatically in Neovim.
  4. Review it, then accept or reject in the agent. On accept, the preview closes automatically.

Then run the one install command for your agent (and apply any agent-specific config):

Claude Code

:CodePreviewInstallClaudeCodeHooks — writes hooks to .claude/settings.local.json. No extra config needed.

Permissions: by default the plugin forces a review prompt on every edit, so the preview always lines up with a real accept/reject moment — even if Claude Code is in bypass/allowlist mode. To instead let Claude Code's own permission settings decide, set diff.defer_claude_permissions = true (you'll then only see previews for edits Claude Code already stops to ask about).

OpenCode

:CodePreviewInstallOpenCodeHooks — copies the plugin to .opencode/plugins/.

Then enable permission prompts in ~/.config/opencode/opencode.json:

Similar plugs

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro,…

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…