Skip to content

Releases: Cannon07/code-preview.nvim

v2.2.0

01 May 20:40

Choose a tag to compare

What's New

OpenAI Codex CLI Backend (#48)

Fourth supported AI backend alongside Claude Code, OpenCode, and Copilot CLI. Install via :CodePreviewInstallCodexCliHooks — writes .codex/hooks.json and detects the required codex_hooks = true feature flag in .codex/config.toml (project or global, with fallback). Both :CodePreviewStatus and :checkhealth code-preview surface flag state so users can self-diagnose silent-no-op failures. Codex's apply_patch (delivered in tool_input.command) is translated into the canonical ApplyPatch shape; Bash passes through.

Shell-Write Detection in the Bash Hook (#48)

> / >> / &> / &>>, mv X.tmp X, cp, tee, and sed -i targets are now flagged in the changes registry as bash_modified / bash_created, so neo-tree shows feedback for shell-driven edits during the approval window — important for Codex GPT models, which prefer the atomic-replace idiom ({ printf …; cat F; } > F.tmp && mv F.tmp F). Includes a looks_like_path filter for false positives leaked from quoted strings (e.g. printf '<!-- … -->\n\n'), tilde expansion, and rm-wins reveal precedence so commands that both rm and write don't double-fire neo-tree reveals.

Configurable Keymaps (#44)

The previously hardcoded mappings (]c, [c, <leader>dq) can now be customized or disabled via a keys table in setup(). Defaults match the prior hardcoded values, so existing users see no change. Set any entry to false to skip that binding, keys = false to skip them all. A <Plug>(CodePreviewCloseAll) mapping is always defined for users who want to bind the close action themselves.

require("code-preview").setup({
  keys = {
    next_change = "]c",
    prev_change = "[c",
    close_all   = "<leader>dq",
  },
})

Bug Fixes

  • ApplyPatch *** Delete File: directives now show the red trash icon in neo-tree (#48) — previously rendered with the orange "modified" pencil. show_diff accepts an explicit action hint so the indicator only switches to deleted when the caller knows it's a delete; legitimate truncate-to-empty edits still render as modified.
  • /tmp/* no longer blanket-filtered from shell-write detection (#48) — on Linux, mktemp paths stay under /tmp, and the over-eager filter was masking real targets. Transience is now signaled by extension (.tmp / .bak / .swp) or /dev/* only.

Documentation

  • README: Codex Quick Start section, including the approval_policy = "on-request" and sandbox_mode = "read-only" settings required for the diff-preview workflow to block on user approval.
  • README: Keymaps section documenting the new keys config and <Plug>(CodePreviewCloseAll).
  • Neovim version floor aligned to >= 0.10 (matches actual vim.uv usage).
  • :checkhealth wording and test-runner examples updated for all four backends.

Migration

No migration required. Existing users are unaffected; Codex support is fully opt-in via :CodePreviewInstallCodexCliHooks, and keymap defaults are unchanged.

Full Changelog

v2.1.0...v2.2.0

v2.1.0

25 Apr 14:40
9ec3a33

Choose a tag to compare

What's New

GitHub Copilot CLI Backend (#42)

Third supported AI backend alongside Claude Code and OpenCode. Install via :CodePreviewInstallCopilotCliHooks — writes a standalone .github/hooks/code-preview.json matching Copilot's auto-discovered multi-file hook contract, so sibling user hooks are never touched. Handles GPT-style apply_patch (raw patch) and Claude-style edit / create / bash tool calls. Status row + :checkhealth coverage included; is_our_config guard prevents uninstall from removing user-owned files that share the name.

OpenCode apply_patch Support (#41)

OpenCode plugin now translates apply_patch tool calls into per-file diff previews using the same custom patch format (*** Begin Patch / *** Update File: / *** Add File: / *** Delete File:).

Configurable Debug Logging (#40)

New debug = true setup option enables structured logs to stdpath('log')/code-preview.log across all hook scripts and Lua modules. Off by default — no log noise unless explicitly enabled.

:CodePreviewStatus Shows All Backends (#38)

Status output now lists every backend's install state (Claude Code, OpenCode, Copilot CLI) with a hint command for any that aren't installed, instead of only reporting the one currently active.

Bug Fixes

  • *** Delete File: directives now close their diff tabs on accept (#42) — the post-tool path extractor previously matched only Update/Add, leaving delete-action diff tabs lingering after mixed update+delete patches.
  • GPT-style *** Add File: patches with no @@ marker now produce non-empty diffs (#42) — lazy hunk creation captures content lines correctly without leaving a stray empty leading hunk when @@ is also present.
  • Adapters bind jq lookup keys via --arg (#42) — removes a future foot-gun where shell-string interpolation could affect the jq program.
  • Malformed Copilot payloads skip cleanly (#42) — empty path for edit/create or empty command for bash now exit 0 rather than push empty-path diffs downstream.

Migration

No migration required. Existing Claude Code and OpenCode users are unaffected; Copilot support is fully opt-in via :CodePreviewInstallCopilotCliHooks.

Full Changelog

v2.0.0...v2.1.0

v2.0.0

17 Apr 21:29
561660d

Choose a tag to compare

What's New

Unified Backend Architecture (#33)

Single core-pre-tool.sh / core-post-tool.sh shared by both Claude Code and OpenCode, replacing separate per-backend shell scripts.

Rename to code-preview.nvim (#34, #35)

All modules, commands, and config keys updated from claude-preview to code-preview. Deprecated aliases for old commands are provided for one release cycle.

Multi-tab Simultaneous Diffs (#37)

Each file edit now opens its own diff tab instead of queuing. Fixes multi-file workflows in OpenCode where all before-hooks fire before any after-hooks.

OpenCode Support (#33)

Full OpenCode backend with :CodePreviewInstallOpenCodeHooks / :CodePreviewUninstallOpenCodeHooks commands.

visible_only Mode (#24)

New config option to skip diff previews for files not open in any Neovim buffer. Toggle at runtime with :CodePreviewToggleVisibleOnly.

Configurable Neo-tree Reveal (#21)

New reveal_root option ("cwd" or "git") for projects where the neo-tree root differs from the working directory.

E2E Test Suite (#19)

Backend shell tests with GitHub Actions CI covering Edit, Write, Bash rm detection, stale socket recovery, and multi-file workflows.

Bug Fixes

  • Fix stale socket and RPC reliability issues (#17)
  • Guard PostToolUse cleanup behind is_open() check (#20)
  • Fix empty old_string handling in apply-edit.lua for new file creation (#37)
  • Fix neo-tree stale tabpage crash — defer neo_tree.refresh() to after tab close (#37)
  • Delayed second refresh so newly created files appear in neo-tree after backend writes them (#37)

Breaking Changes

  • Renamed from claude-preview to code-preview — update your require() calls and config. Old :ClaudePreview* commands still work but will be removed in a future release.
  • Removed auto_close config option — diffs now always close via the post-hook. Remove auto_close = true from your config if present.

Full Changelog

v1.1.0...v2.0.0

v1.1.0

29 Mar 12:02
4aee3b0

Choose a tag to compare

What's New

OpenCode support (#12)

claude-preview.nvim now supports OpenCode as an alternative backend alongside Claude Code. Install with :CodePreviewInstallOpenCodeHooks — no dependencies required.

GitHub-style inline diff layout (#10, #11)

New "inline" diff layout with syntax highlighting, character-level diffs, sign column indicators, and ]c/[c navigation.

require("claude-preview").setup({
  diff = { layout = "inline" },
})

Neo-tree integration (#3)

File tree indicators show which files are being modified, created, or deleted. Works out of the box with neo-tree.nvim.

Other improvements

  • Discover Neovim sockets in XDG_RUNTIME_DIR for NixOS/systemd-based distros (#4)
  • Fix diffoff before closing diff windows to prevent Neovim crash (#6)

Full Changelog: v1.0.0...v1.1.0