feat(highlight): wire highlights.context config into treesitter pipeline

Problem: `highlights.context.enabled` and `highlights.context.lines` were
defined, validated, and range-checked but never read during highlighting.
Hunks inside incomplete constructs (e.g., a table literal or function body
whose opening is beyond the hunk's own context lines) parsed incorrectly.

Solution: `compute_hunk_context` reads the working tree file using the
hunk's `@@ +start,count @@` line numbers to collect surrounding code.
Files are read once and cached across hunks. `highlight_treesitter` accepts
an optional context parameter that prepends/appends context lines to the
parse string, offsetting capture rows so extmarks only land on hunk lines.
This commit is contained in:
Barrett Ruth 2026-03-05 11:09:56 -05:00
parent e1d3b81607
commit 70e623fcce
5 changed files with 534 additions and 17 deletions

View file

@ -15,6 +15,8 @@
---@field prefix_width integer
---@field quote_width integer
---@field repo_root string?
---@field context_before string[]?
---@field context_after string[]?
local M = {}