Cannon07

Code Preview.Nvim — Data & AI agent for Claude Code

Data & AI community intermediate

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

How to install Code Preview.Nvim

This entry records only its repository, not the path inside it, so there is no exact command to give. Open Cannon07/code-preview.nvim and copy the folder into ~/.claude/agents/.

What Code Preview.Nvim does

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

Alternatives in Data & AI

  • Claude Mem — A Claude Code plugin that automatically captures everything Claude does during your coding sessions, compresse 38.9k ★
  • Crush — The glamourous AI coding agent for your favourite terminal 21.8k ★
  • Visual Explainer — Agent skill + prompt templates that generate rich HTML pages for visual diff reviews, architecture overviews 6.8k ★

README

code-preview.nvim

A Neovim plugin that shows a **diff preview before your AI coding agent applies any file change** — letting you review exactly what's changing before accepting.

Supports [Claude Code](https://docs.anthropic.com/en/docs/claude-code) and [OpenCode](https://opencode.ai) as backends.


Demo

Claude Code

![Claude Code demo](docs/claude-preview-demo.gif)

OpenCode

![OpenCode demo](docs/claude-preview-opencode.gif)


Table of Contents


Features

  • Diff preview — side-by-side or inline diff opens in Neovim before any file is written
  • Multiple layouts — tab, vsplit, or GitHub-style inline diff with syntax highlighting
  • Neo-tree integration — file tree indicators show which files are being modified, created, or deleted
  • Multi-backend — works with Claude Code CLI and OpenCode
  • No Python dependency — file transformations use nvim --headless -l

Requirements

  • Neovim >= 0.9

**For Claude Code backend:**

**For OpenCode backend:**


Installation

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()

Quick Start

Claude Code

  1. Install the plugin and call setup()
  2. Open a project in Neovim
  3. Run :CodePreviewInstallClaudeCodeHooks — writes hooks to .claude/settings.local.json
  4. Restart Claude Code CLI in the project directory
  5. Ask Claude to edit a file — a diff opens automatically in Neovim
  6. Accept/reject in the CLI; the diff closes automatically on accept
  7. If rejected, press dq to close the diff manually

OpenCode

  1. Install the plugin and call setup()
  2. Open a project in Neovim
  3. Run :CodePreviewInstallOpenCodeHooks — copies the plugin to .opencode/plugins/
  4. Ensure your OpenCode config (~/.config/opencode/opencode.json) has permission prompts enabled:
    {
      "permission": {
        "edit": "ask",
        "bash": "ask"
      }
    }
  5. Start OpenCode in the project directory
  6. Ask OpenCode to edit a file — a diff opens automatically in Neovim
  7. Accept/reject in OpenCode; the diff closes automatically on accept
  8. If rejected, press dq to close the diff manually

How it works

AI