code-preview.nvim: review agent edits in Neovim

code-preview.nvim

A Neovim plugin: edits from Claude Code, OpenCode, Copilot CLI and Codex CLI open as a native diff before they hit disk

  • 185 ★ on the repository
  • Last commit
  • MIT
Plugin

Extended access

Why this level

  • Installation changes agent settings: hooks in `.claude/settings.local.json`, `.codex/hooks.json` or `.github/hooks/`
  • By default the plugin forces the agent to ask for approval on every edit, which changes how Claude Code behaves
All reasons and checks

cannon07/code-preview.nvim

Install

Manual install

:CodePreviewInstallClaudeCodeHooks

A Neovim command, not a shell one. It writes hooks into `.claude/settings.local.json`; then restart Claude Code.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • Installation changes agent settings: hooks in `.claude/settings.local.json`, `.codex/hooks.json` or `.github/hooks/`
  • By default the plugin forces the agent to ask for approval on every edit, which changes how Claude Code behaves

This is third-party code. Review the repository files before installing.

What it does

An agent shows an edit in the terminal, where the diff is cramped and scrolls past. code-preview.nvim intercepts that moment through the agent's hooks and opens the proposed change in Neovim, with syntax highlighting, your colorscheme and your keymaps. The decision is still made in the agent, and the preview closes after you accept. It works with Claude Code, OpenCode, GitHub Copilot CLI and OpenAI Codex CLI on macOS, Linux and Windows. The diff layout is set with `diff.layout`: a tab with the current and proposed versions side by side, a vertical split or a GitHub-style inline diff. With Neo-tree open, the file tree marks files being modified, created or deleted. Each agent has its own hook install command: `:CodePreviewInstallClaudeCodeHooks` writes hooks into `.claude/settings.local.json`, `:CodePreviewInstallOpenCodeHooks` copies the plugin into `.opencode/plugins/`. Matching `:CodePreviewUninstall…` commands remove them.

Who it is for. People who live in Neovim and read agent edits as an ordinary diff, and find the terminal view before approval hard to use.

Good fit when

  • Claude Code proposes an edit across several files and it reads better side by side in Neovim
  • A team uses different agents and wants the same edit review for all of them
  • Neo-tree should show which files the agent is about to change
  • The edit is large and without syntax highlighting in the terminal it is easy to accept unread
  • The work is on Windows: the Copilot CLI hook runs in PowerShell 7 there and does without `jq`

Not a fit when

  • The editor is not Neovim: the preview opens only there
  • The agent runs in a full-permission mode without prompts and its approval settings cannot be changed
  • Codex creates files through shell redirection: such files do not appear in the preview
  • Neovim is older than 0.10

Example request

Rename the function loadConfig to readConfig across the src files and show me the edit in Neovim before it is written.

Limitations

Neovim 0.10 or newer is required. Claude Code and Codex CLI also need `jq` installed.

By default the plugin forces an approval prompt on every edit, including in Claude Code's permission-bypass mode. To let the agent's own settings decide, set `diff.defer_claude_permissions = true`.

When an edit is rejected, the Claude Code and Copilot CLI hooks do not fire, so the preview is closed by hand with `<leader>dq` or `:CodePreviewCloseDiff`. Codex must ask before editing, which takes `approval_policy = "on-request"` and `sandbox_mode = "read-only"` in its config. The last commit is from June 2026.

How to disable. Each agent has a matching command, for example `:CodePreviewUninstallClaudeCodeHooks`. It removes the hooks from the agent settings, after which the plugin can be dropped from the Neovim manager.

FAQ

How do I preview Claude Code edits in Neovim?

Install the plugin through lazy.nvim, call `setup()`, then run `:CodePreviewInstallClaudeCodeHooks` in Neovim and restart Claude Code. The hooks go into `.claude/settings.local.json`; no further setup is needed.

The preview stayed open after I rejected the edit, what now?

Press `<leader>dq` or run `:CodePreviewCloseDiff`. After an accepted edit the preview closes itself, while on rejection the Claude Code and Copilot CLI hooks are not called.

Is Python required?

No. File transforms run through `nvim --headless -l`, and the only hard dependency is Neovim 0.10 or newer. Claude Code and Codex CLI also need `jq`.

Which diff layouts exist?

Three, set with `diff.layout`: `"tab"` by default, a tab with the current and proposed versions side by side, `"vsplit"` as a vertical split and `"inline"` for an inline diff.

Which agents are supported and how?

Claude Code, GitHub Copilot CLI and Codex CLI through shell hooks, OpenCode through a TypeScript plugin in `.opencode/plugins/`. Each has a matching `:CodePreviewUninstall…` command.

Discussion

No questions or reviews yet.

Plugins
Needs a VPN

Neovim plugin that connects Claude Code to the editor: current file, selection, diagnostics and diff review of proposed edits

PluginExtended access3.2KRepository stars

CodeCompanion.nvim

codecompanion.nvim

A Neovim AI assistant with LLM chat and Claude Code, Codex, Gemini CLI running right inside the editor via ACP and MCP

PluginExtended access6.9KRepository stars

A CLI opens diffs and documents in a terminal so a person can annotate lines and pass feedback to a coding agent

CLIExtended access945Repository stars

A code-review CLI and plugin for agents: reads a git diff and writes line-level comments with context

CLIExtended access49.6KRepository stars

A file tree plugin for Claude Code that highlights the files the agent reads and edits, with git status, diffs and a preview

PluginExtended access377Repository stars

A Claude Code plugin: 39 commands for PRs, review, commits and specs, nine expert roles and hooks, in eight language versions

PluginBroad access1.1KRepository stars

README in short

The flow is: install the plugin, run the hook command for each agent, restart the CLI and review. A table shows each agent's mechanism: shell hooks or a TypeScript plugin. Separate sections cover diff layouts, keymaps and Neo-tree integration.

README badge

Report a problem

Foxx AIcode-preview.nvim: review agent edits in Neovim
Foxx AI

I am Foxx AI and I have already vetted this tool. Ask about install, setup or anything else, and I will keep it simple.