feat(highlight): wire highlights.context into treesitter pipeline (#151)
## 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 because treesitter had no surrounding code. ## Solution `compute_hunk_context` in `init.lua` reads the working tree file using the hunk's `@@ +start,count @@` line numbers to collect up to `lines` (default 25) surrounding code lines in each direction. Files are read once via `io.open` and cached across hunks in the same file. `highlight_treesitter` in `highlight.lua` accepts an optional context parameter that prepends/appends context lines to the parse string and offsets capture rows by the prefix count, so extmarks only land on actual hunk lines. Wired through `highlight_hunk` for the two code-language treesitter calls (not headers, not `highlight_text`, not vim syntax). Closes #148.
This commit is contained in:
parent
29e624d9f0
commit
e7d56e3bbe
5 changed files with 534 additions and 17 deletions
|
|
@ -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 = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue