diff --git a/lua/diffs/highlight.lua b/lua/diffs/highlight.lua index 2a2f8b1..a63cf4e 100644 --- a/lua/diffs/highlight.lua +++ b/lua/diffs/highlight.lua @@ -370,7 +370,17 @@ function M.highlight_hunk(bufnr, ns, hunk, opts) header_map[i] = hunk.header_start_line - 1 + i end extmark_count = extmark_count - + highlight_treesitter(bufnr, ns, hunk.header_lines, 'diff', header_map, qw, nil, p, qw > 0 or pw > 1) + + highlight_treesitter( + bufnr, + ns, + hunk.header_lines, + 'diff', + header_map, + qw, + nil, + p, + qw > 0 or pw > 1 + ) end local at_raw_line diff --git a/spec/highlight_spec.lua b/spec/highlight_spec.lua index 4695d66..58028c9 100644 --- a/spec/highlight_spec.lua +++ b/spec/highlight_spec.lua @@ -1669,7 +1669,13 @@ describe('highlight', function() local high_prio_diff = {} for _, mark in ipairs(extmarks) do local d = mark[4] - if mark[2] < 4 and d and d.hl_group and d.hl_group:match('^@.*%.diff$') and (d.priority or 0) >= 199 then + if + mark[2] < 4 + and d + and d.hl_group + and d.hl_group:match('^@.*%.diff$') + and (d.priority or 0) >= 199 + then high_prio_diff[mark[2]] = true end end @@ -1727,8 +1733,14 @@ describe('highlight', function() end end end - assert.is_true(minus_prio > punct_prio_minus, '@diff.minus.diff should beat @punctuation.special.diff on --- line') - assert.is_true(plus_prio > punct_prio_plus, '@diff.plus.diff should beat @punctuation.special.diff on +++ line') + assert.is_true( + minus_prio > punct_prio_minus, + '@diff.minus.diff should beat @punctuation.special.diff on --- line' + ) + assert.is_true( + plus_prio > punct_prio_plus, + '@diff.plus.diff should beat @punctuation.special.diff on +++ line' + ) delete_buffer(bufnr) end) @@ -1764,7 +1776,13 @@ describe('highlight', function() local has_keyword = false for _, mark in ipairs(extmarks) do local d = mark[4] - if mark[2] == 1 and d and d.hl_group == '@keyword.diff' and mark[3] == 0 and (d.end_col or 0) == 5 then + if + mark[2] == 1 + and d + and d.hl_group == '@keyword.diff' + and mark[3] == 0 + and (d.end_col or 0) == 5 + then has_keyword = true end end