refactor: extract generated buffer metadata helpers #147

Closed
opened 2026-09-21 18:12:32 +00:00 by barrettruth · 0 comments
Owner

Original issue: barrettruth/diffs.nvim#342
Original author: barrettruth
Original date: 2026-05-13T17:34:03Z

Tracked By

Context

Generated diffs:// buffers are now a large part of the plugin surface. Their identity and reload metadata are still a cross-module convention rather than an owned API.

Problem

lua/diffs/commands.lua owns diffs_source schema review, generated buffer var setup, and reload dispatch. Nearby modules also read or normalize the same state directly:

  • lua/diffs/split.lua
  • lua/diffs/lists.lua
  • lua/diffs/actions.lua
  • lua/diffs/hunks.lua

That makes generated view identity harder to reason about while reviewing config and docs changes.

Scope

Add a small generated-buffer metadata module for buffer-local accessors and source constructors/normalizers around:

  • diffs_repo_root
  • diffs_spec
  • diffs_hunks
  • diffs_source

Keep commands.read_buffer() behavior unchanged.

Acceptance Criteria

  • existing diffs:// buffer names are unchanged
  • buffer-local vars remain compatible
  • reload behavior is unchanged
  • hunk action maps keep working
  • split endpoint reload behavior is unchanged
  • invalid metadata still warns with equivalent messages
  • commands.lua no longer defines the whole generated-source validator inline

Suggested Readiness

> Original issue: barrettruth/diffs.nvim#342 > Original author: `barrettruth` > Original date: 2026-05-13T17:34:03Z ## Tracked By - #315 ## Context Generated `diffs://` buffers are now a large part of the plugin surface. Their identity and reload metadata are still a cross-module convention rather than an owned API. ## Problem `lua/diffs/commands.lua` owns `diffs_source` schema review, generated buffer var setup, and reload dispatch. Nearby modules also read or normalize the same state directly: - `lua/diffs/split.lua` - `lua/diffs/lists.lua` - `lua/diffs/actions.lua` - `lua/diffs/hunks.lua` That makes generated view identity harder to reason about while reviewing config and docs changes. ## Scope Add a small generated-buffer metadata module for buffer-local accessors and source constructors/normalizers around: - `diffs_repo_root` - `diffs_spec` - `diffs_hunks` - `diffs_source` Keep `commands.read_buffer()` behavior unchanged. ## Acceptance Criteria - existing `diffs://` buffer names are unchanged - buffer-local vars remain compatible - reload behavior is unchanged - hunk action maps keep working - split endpoint reload behavior is unchanged - invalid metadata still warns with equivalent messages - `commands.lua` no longer defines the whole generated-source validator inline ## Suggested Readiness ```sh ```
barrettruth 2026-09-21 18:12:32 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
barrettruth/diffs.nvim#147
No description provided.