Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .claude-plugin/skills/revdiff/references/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ revdiff --dump-theme > ~/.config/revdiff/themes/my-custom # export current colo

Set default theme in config: `theme = dracula`. Or env: `REVDIFF_THEME=dracula`.

**Custom themes:** customize colors in config or via `--color-*` flags, then `revdiff --dump-theme > ~/.config/revdiff/themes/my-custom`. Or copy a bundled theme file and edit directly — each has all 21 color keys + `chroma-style`.
**Custom themes:** customize colors in config or via `--color-*` flags, then `revdiff --dump-theme > ~/.config/revdiff/themes/my-custom`. Or copy a bundled theme file and edit directly — each has all 23 color keys + `chroma-style`.

Precedence: `--theme` takes over completely — overwrites all color fields, ignoring `--color-*` flags and env vars. Without `--theme`: built-in defaults → config file → env vars → CLI flags. `--theme` + `--no-colors` prints warning and applies theme.

Expand All @@ -94,6 +94,8 @@ All color options accept hex values (`#rrggbb`) and have corresponding `REVDIFF_
| `--color-add-bg` | Added line background | `#123800` |
| `--color-remove-fg` | Removed line text | `#ff8787` |
| `--color-remove-bg` | Removed line background | `#4D1100` |
| `--color-word-add-bg` | Intra-line word-diff add background | auto-derived from add-bg |
| `--color-word-remove-bg` | Intra-line word-diff remove background | auto-derived from remove-bg |
| `--color-modify-fg` | Modified line text (collapsed mode) | `#f5c542` |
| `--color-modify-bg` | Modified line background (collapsed mode) | `#3D2E00` |
| `--color-tree-bg` | File tree pane background | terminal default |
Expand Down
14 changes: 11 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ TUI for reviewing diffs, files, and documents with inline annotations, built wit
- `annotlist.go` - annotation list overlay
- `mdtoc.go` - markdown TOC component
- `search.go` - search input and navigation
- `worddiff.go` - intra-line word-diff: tokenizer, LCS, line pairing, range computation
- `colorutil.go` - color utility: HSL conversion, shiftLightness for auto-deriving word-diff bg
- `styles.go` - lipgloss styles and theme integration
- `app/highlight/` - chroma-based syntax highlighting, foreground-only ANSI output
- `app/keymap/` - user-configurable keybindings (`Action` constants, `Keymap` type, parser, defaults, dump)
Expand All @@ -44,8 +46,14 @@ git diff → diff.parseUnifiedDiff() → []DiffLine
(or: disk file → diff.readFileAsContext() → []DiffLine, all ChangeContext)
(or: stdin / arbitrary reader → diff.readReaderAsContext() → []DiffLine, all ChangeContext)
→ highlight.HighlightLines() → []string (ANSI foreground-only)
→ recomputeIntraRanges(): pairs add/remove lines within hunks via pairHunkLines(),
runs token-level LCS diff (changedTokenRanges) on each pair, stores [][]matchRange
parallel to diffLines. 30% similarity gate discards ranges for dissimilar pairs.
Ranges are byte offsets on tab-replaced content, aligning with prepareLineContent output.
→ ui.renderDiff() dispatches:
expanded (default): renderDiffLine() for each line
intra-line word-diff: when intraRanges[idx] is non-nil, insertHighlightMarkers()
adds WordAddBg/WordRemoveBg ANSI bg markers around changed spans (reverse-video in no-color mode)
collapsed (`v` toggle): renderCollapsedDiff() → skips removed lines,
uses buildModifiedSet() to style adds as modify (amber ~) or pure add (green +)
expanded hunks (`.` toggle) show all lines inline
Expand All @@ -62,9 +70,9 @@ git diff → diff.parseUnifiedDiff() → []DiffLine
wrapContent() splits long lines via ansi.Wrap,
continuation lines get `↪` gutter marker, cursorViewportY() sums wrapped line counts.
ansi.Wrap does not preserve SGR state across inserted newlines, so reemitANSIState()
re-prepends active fg color, bold, and italic at the start of each continuation line.
re-prepends active fg color, bold, italic, and bg at the start of each continuation line.
State tracking via scanANSIState()/parseSGR()/applySGR(); handles chroma's fg (24-bit/basic),
bold (1/22), italic (3/23), fg reset (39), and full reset (0/bare)
bold (1/22), italic (3/23), bg (48;2;r;g;b/49), fg reset (39), and full reset (0/bare)
when search is active (`/` to search, `n`/`N` to navigate, `esc` to clear):
buildSearchMatchSet() converts match indices to O(1) map per render,
highlightSearchMatches() inserts ANSI bg-only sequence around matched substrings
Expand All @@ -85,7 +93,7 @@ git diff → diff.parseUnifiedDiff() → []DiffLine
- `no-ini:"true"` tag excludes fields from config file (used for --config, --dump-config, --dump-theme, --list-themes, --init-themes, --version)
- Themes dir: `~/.config/revdiff/themes/` with 7 bundled themes (revdiff, catppuccin-mocha, catppuccin-latte, dracula, gruvbox, nord, solarized-dark), auto-created on first run
- `--theme NAME` loads theme; `--dump-theme` exports resolved colors; `--list-themes` lists available; `--init-themes` re-creates bundled
- Theme precedence: `--theme` takes over completely — overwrites all 21 color fields + chroma-style, ignoring any `--color-*` flags or env vars. `--theme` + `--no-colors` prints warning and applies theme.
- Theme precedence: `--theme` takes over completely — overwrites all 23 color fields + chroma-style, ignoring any `--color-*` flags or env vars. `--theme` + `--no-colors` prints warning and applies theme.
- Theme values applied via `applyTheme()` in `main.go` which directly overwrites `opts.Colors.*` fields after `parseArgs()`. `colorFieldPtrs(opts)` is the single source of truth for the color key → struct field mapping, used by both `applyTheme()` and `collectColors()` — adding a new color requires changes in `theme.go` colorKeys + options struct + `colorFieldPtrs()`
- `ini-name` tags ensure config keys match CLI long flag names
- Keybindings file: `~/.config/revdiff/keybindings` (`map <key> <action>` / `unmap <key>` format)
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Built for a specific use case: reviewing code changes, plans, and documents with

- Structured annotation output to stdout - pipe into AI agents, scripts, or other tools
- Full-file diff view with syntax highlighting
- Intra-line word-diff: highlights the specific changed words within paired add/remove lines using a brighter background overlay, always on
- Collapsed diff mode: shows final text with change markers, toggle with `v`
- Word wrap mode: wraps long lines at viewport boundary with `↪` continuation markers, toggle with `w`
- Line numbers: side-by-side old/new line number gutter, toggle with `L`
Expand Down Expand Up @@ -295,15 +296,15 @@ revdiff --dump-theme > ~/.config/revdiff/themes/my-custom
**Creating custom themes** — two approaches:

1. **From current colors:** customize individual colors in your config file or via `--color-*` flags, then dump the resolved result as a theme: `revdiff --dump-theme > ~/.config/revdiff/themes/my-custom`
2. **From scratch:** copy a bundled theme and edit it directly — each file defines all 21 color keys plus `chroma-style` in INI format:
2. **From scratch:** copy a bundled theme and edit it directly — each file defines all 23 color keys plus `chroma-style` in INI format:

```ini
# name: my-custom
# description: custom color scheme
chroma-style = dracula
color-accent = #bd93f9
color-border = #6272a4
...all 21 color keys...
...all 23 color keys...
```

Set a default theme in the config file:
Expand All @@ -316,7 +317,7 @@ Or via environment variable: `REVDIFF_THEME=dracula`.

**Contributing themes** — community themes live in the `themes/gallery/` directory. See [themes/README.md](themes/README.md) for the contribution guide, format requirements, and validation instructions.

**Precedence:** When `--theme` is set, it takes over completely — all 21 color fields and chroma-style are overwritten by the theme, ignoring any `--color-*` flags or env vars. Without `--theme`: built-in defaults → config file → env vars → CLI flags. `--theme` + `--no-colors` prints a warning and applies the theme.
**Precedence:** When `--theme` is set, it takes over completely — all 23 color fields and chroma-style are overwritten by the theme, ignoring any `--color-*` flags or env vars. Without `--theme`: built-in defaults → config file → env vars → CLI flags. `--theme` + `--no-colors` prints a warning and applies the theme.

<details>
<summary>Color customization flags (click to expand)</summary>
Expand All @@ -338,6 +339,8 @@ All color options accept hex values (`#rrggbb`) and have corresponding `REVDIFF_
| `--color-add-bg` | Added line background | `#123800` |
| `--color-remove-fg` | Removed line text | `#ff8787` |
| `--color-remove-bg` | Removed line background | `#4D1100` |
| `--color-word-add-bg` | Intra-line word-diff add background | auto-derived from add-bg |
| `--color-word-remove-bg` | Intra-line word-diff remove background | auto-derived from remove-bg |
| `--color-modify-fg` | Modified line text (collapsed mode) | `#f5c542` |
| `--color-modify-bg` | Modified line background (collapsed mode) | `#3D2E00` |
| `--color-tree-bg` | File tree pane background | terminal default |
Expand Down
Loading
Loading