refactor: change highlights.context config to table structure
Problem: highlights.context was a plain integer, inconsistent with the
table structure used by treesitter, vim, and intra sub-configs.
Solution: change to { enabled = true, lines = 25 } with full
vim.validate() coverage matching the existing pattern.
This commit is contained in:
parent
2e1ebdee03
commit
9e32384f18
5 changed files with 76 additions and 29 deletions
|
|
@ -56,7 +56,10 @@ Configuration is done via `vim.g.diffs`. Set this before the plugin loads:
|
|||
highlights = {
|
||||
background = true,
|
||||
gutter = true,
|
||||
context = 25,
|
||||
context = {
|
||||
enabled = true,
|
||||
lines = 25,
|
||||
},
|
||||
treesitter = {
|
||||
enabled = true,
|
||||
max_lines = 500,
|
||||
|
|
@ -114,15 +117,9 @@ Configuration is done via `vim.g.diffs`. Set this before the plugin loads:
|
|||
Highlight line numbers with matching colors.
|
||||
Only visible if line numbers are enabled.
|
||||
|
||||
{context} (integer, default: 25)
|
||||
Number of lines to read from the source file
|
||||
before and after each hunk for syntax parsing
|
||||
context. Improves accuracy at hunk boundaries
|
||||
where incomplete constructs (e.g., a function
|
||||
definition with no body) would otherwise confuse
|
||||
the parser. Set to 0 to disable. Lines are read
|
||||
from disk with early exit — cost scales with the
|
||||
context value, not file size.
|
||||
{context} (table, default: see below)
|
||||
Syntax parsing context options.
|
||||
See |diffs.ContextConfig| for fields.
|
||||
|
||||
{treesitter} (table, default: see below)
|
||||
Treesitter highlighting options.
|
||||
|
|
@ -136,6 +133,20 @@ Configuration is done via `vim.g.diffs`. Set this before the plugin loads:
|
|||
Character-level (intra-line) diff highlighting.
|
||||
See |diffs.IntraConfig| for fields.
|
||||
|
||||
*diffs.ContextConfig*
|
||||
Context config fields: ~
|
||||
{enabled} (boolean, default: true)
|
||||
Read lines from disk before and after each hunk
|
||||
to provide surrounding syntax context. Improves
|
||||
accuracy at hunk boundaries where incomplete
|
||||
constructs (e.g., a function definition with no
|
||||
body) would otherwise confuse the parser.
|
||||
|
||||
{lines} (integer, default: 25)
|
||||
Number of context lines to read in each
|
||||
direction. Lines are read with early exit —
|
||||
cost scales with this value, not file size.
|
||||
|
||||
*diffs.TreesitterConfig*
|
||||
Treesitter config fields: ~
|
||||
{enabled} (boolean, default: true)
|
||||
|
|
@ -318,13 +329,13 @@ Incomplete Syntax Context ~
|
|||
*diffs-syntax-context*
|
||||
Treesitter parses each diff hunk in isolation. To provide surrounding code
|
||||
context, diffs.nvim reads lines from disk before and after each hunk
|
||||
(controlled by `highlights.context`, default 25). This resolves most boundary
|
||||
(see |diffs.ContextConfig|, enabled by default). This resolves most boundary
|
||||
issues where incomplete constructs (e.g., a function definition at the edge
|
||||
of a hunk with no body) would confuse the parser.
|
||||
|
||||
Set `highlights.context = 0` to disable context padding and restore the
|
||||
previous behavior. In rare cases, context padding may not help if the
|
||||
relevant surrounding code is very far from the hunk boundaries.
|
||||
Set `highlights.context.enabled = false` to disable context padding. In rare
|
||||
cases, context padding may not help if the relevant surrounding code is very
|
||||
far from the hunk boundaries.
|
||||
|
||||
Syntax Highlighting Flash ~
|
||||
*diffs-flash*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue