refactor(highlight): unified per-line extmark builder in highlight_hunk
Problem: highlight_hunk applied DiffsClear extmarks across 5 scattered sites with ad-hoc column arithmetic. highlight_hunk_vim_syntax duplicated the inline vim syntax path, and the deferred pass in init.lua double-called it, creating duplicate scratch buffers and extmarks. Solution: reorganize highlight_hunk into two clean phases: - Phase 1: multi-line syntax computation (treesitter, vim syntax, diff grammar, header context text) — sets syntax extmarks only - Phase 2: per-line chrome (DiffsClear, backgrounds, gutter, overlays, intra-line) — all non-syntax extmarks in one unified pass Hoist new_code to function scope (needed by highlight_text outside the use_ts block). Hoist at_raw_line so Phase 1d and Phase 2b share it. Delete highlight_hunk_vim_syntax (redundant with inline path). Remove the double-call from the deferred pass in init.lua.
This commit is contained in:
parent
749a21ae3c
commit
d7ee488ef3
2 changed files with 73 additions and 60 deletions
|
|
@ -411,7 +411,7 @@ local function compute_highlight_groups()
|
|||
local blended_add_text = blend_color(add_fg, bg, alpha)
|
||||
local blended_del_text = blend_color(del_fg, bg, alpha)
|
||||
|
||||
vim.api.nvim_set_hl(0, 'DiffsClear', { default = true, fg = normal.fg or 0xc0c0c0 })
|
||||
vim.api.nvim_set_hl(0, 'DiffsClear', { default = true, fg = normal.fg or 0xc0c0c0, bg = bg })
|
||||
vim.api.nvim_set_hl(0, 'DiffsAdd', { default = true, bg = blended_add })
|
||||
vim.api.nvim_set_hl(0, 'DiffsDelete', { default = true, bg = blended_del })
|
||||
vim.api.nvim_set_hl(0, 'DiffsAddNr', { default = true, fg = blended_add_text, bg = blended_add })
|
||||
|
|
@ -797,9 +797,6 @@ local function init()
|
|||
end
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, start_row, end_row)
|
||||
highlight.highlight_hunk(bufnr, ns, hunk, full_opts)
|
||||
if not hunk.lang and hunk.ft then
|
||||
highlight.highlight_hunk_vim_syntax(bufnr, ns, hunk, full_opts)
|
||||
end
|
||||
end
|
||||
if t1 then
|
||||
dbg('deferred pass: %d hunks in %.2fms', #deferred_syntax, (vim.uv.hrtime() - t1) / 1e6)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue