Skip to content

Latest commit

 

History

History
142 lines (116 loc) · 6.27 KB

README.md

File metadata and controls

142 lines (116 loc) · 6.27 KB

purrview.nvim

A minimap for Neovim. A strip on the right edge of the window shows the code's shape in syntax colours, plus git hunks, diagnostics, search matches, the visual selection, the visible range and the cursor row.

purrview's Kitty-graphics minimap beside Lua code in Ghostty

Renderer tiers

How the strip is drawn depends on what the terminal supports:

kitty braille blocks
kitty tier braille tier blocks tier
A pixel image. Needs the Kitty graphics protocol with Unicode placeholders: Ghostty, Kitty and other libghostty-based terminals, or tmux with allow-passthrough inside one of them. 2×4 braille dots per cell, coloured by syntax. Needs termguicolors. Coloured rails and row tints, no code shape. Works without termguicolors.

With the default renderer = "auto", the strip starts on braille (or blocks when termguicolors is off) and probes the terminal for Kitty graphics. If the terminal answers, it switches to the image. If the terminal later rejects an image, it falls back to braille. :checkhealth purrview shows the tier in use and why.

To force a tier, set renderer = "kitty" | "braille" | "blocks", or override it per session with vim.g.purrview_renderer or $PURRVIEW_RENDERER.

What the strip shows

  • Hunks on a rail along the left edge: added, changed and deleted lines in the hunk colours. Changed lines also stand out across the strip: tinted in kitty and blocks, with their braille dots in the hunk colour. The hunk under the cursor is outlined (kitty) or drawn as a full block (braille, blocks).
  • Diagnostics on a rail along the right edge, the most severe per line first (warnings and errors by default).
  • The code shape, dimmed so the rails stay the brightest marks.
  • The visible range as a lighter band, and the cursor row as a brighter one.
  • Search matches while 'hlsearch' is on, and the visual selection.

Mark colours come from your colourscheme (the gitsigns or mini.diff sign colours if those are defined, else the built-in Added/Changed/Removed groups and Diagnostic*). Any colour that would be hard to see against the strip is lightened (dark themes) or darkened (light themes) until it reaches emphasis.min_contrast.

The strip floats over the window's rightmost text columns: 12 cells wide for kitty, 10 for braille, 2 for blocks (width option). Windows narrower than 60 columns get no strip (editor.min_window_width).

Requirements

  • Neovim 0.12+
  • termguicolors for the kitty and braille tiers

Install

-- lazy.nvim
{ "CoreyKaylor/purrview.nvim", opts = {} }

setup() is optional. Without it, :Purrview uses the defaults.

Usage

  • :Purrview toggles the minimap on the current window. :Purrview open, close and refresh do what they say. :Purrview info prints the tier in use and paint counters.
  • Click or drag on the strip to jump there; scroll the mouse wheel over it to scroll the window.
  • editor = { auto = true } opens a minimap on every eligible window.
require("purrview").setup({
  editor = { auto = true },                -- a minimap on every eligible window
  git = { source = "auto" },               -- gitsigns → mini.diff → builtin index diff
  diagnostics = { min_severity = "warn" }, -- "error" | "warn" | "info" | "hint"
  emphasis = { code_alpha = 0.5 },         -- lower: dimmer code, marks pop more
  integrations = { diffbandit = { enabled = true } }, -- false: skip diff tabs
})

Every option, with defaults, is in :help purrview-config.

Integrations

  • gitsigns.nvim / mini.diff: when either is attached to the buffer, purrview shows its hunks and repaints on its updates. Without them, purrview diffs the buffer against the git index itself, in the background. git.source picks one explicitly, or false turns hunks off.
  • diffbandit.nvim: diff panes get a minimap of the diff session's own hunks. Set integrations.diffbandit.enabled = false to leave diff tabs alone. Plugins that manage their own windows can place a strip themselves with require("purrview").attach{ target, placement, source } and placement.managed(...).

Development

make deps              # mini.nvim (for mini.test) into deps/
make test              # unit + functional specs
make test-integration  # real-terminal scenarios through herdr (needs herdr, tmux)
make test-visual       # Ghostty screenshots vs references (macOS only)
make lint              # stylua + selene

The tests come in four layers:

  • tests/unit: pure modules: raster layout and paint order, braille and block grids, line/row projection, Kitty protocol encoding, hunk parsing, colour contrast.
  • tests/functional: a fresh child Neovim per case: window lifecycle, mouse, the Kitty transport (through a capture sink), probe/fallback/rejection, search and selection in every tier, the git index source and real mini.diff in temp repos, the diffbandit integration, and reference screenshots of the braille and blocks tiers.
  • tests/integration/herdr: each scenario runs Neovim in a pane of an isolated, headless herdr session, a real terminal emulator that answers the Kitty graphics probe. The screen is read back and checked: image placeholder cells carry purrview's image id, rail cells have the right colours. Scenarios cover each tier, scrolling, tmux with and without passthrough, and live git edits.
  • tests/visual/ghostty: each scene runs in a real Ghostty window, is screenshotted, and compared with a reference image, both whole-window and for the strip alone. Needs Screen Recording permission for your terminal; UPDATE=1 rewrites the references. The images in this README come from these scenes.