From b3e687c954c3080f1696b62a8aaf719815810a8c Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 2 Feb 2026 00:35:08 -0500 Subject: [PATCH] fix: proper background higlights --- lua/fugitive-ts/highlight.lua | 2 +- lua/fugitive-ts/init.lua | 5 +++++ spec/highlight_spec.lua | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lua/fugitive-ts/highlight.lua b/lua/fugitive-ts/highlight.lua index 8c821fb..f8cc026 100644 --- a/lua/fugitive-ts/highlight.lua +++ b/lua/fugitive-ts/highlight.lua @@ -146,7 +146,7 @@ function M.highlight_hunk(bufnr, ns, hunk, opts) end if opts.highlights.background and (prefix == '+' or prefix == '-') then - local line_hl = prefix == '+' and 'DiffAdd' or 'DiffDelete' + local line_hl = prefix == '+' and 'FugitiveTsAdd' or 'FugitiveTsDelete' local extmark_opts = { line_hl_group = line_hl, priority = 198, diff --git a/lua/fugitive-ts/init.lua b/lua/fugitive-ts/init.lua index 1e19c03..e3f053e 100644 --- a/lua/fugitive-ts/init.lua +++ b/lua/fugitive-ts/init.lua @@ -183,6 +183,11 @@ function M.setup(opts) config = vim.tbl_deep_extend('force', default_config, opts) parser.set_debug(config.debug) highlight.set_debug(config.debug) + + local diff_add = vim.api.nvim_get_hl(0, { name = 'DiffAdd' }) + local diff_delete = vim.api.nvim_get_hl(0, { name = 'DiffDelete' }) + vim.api.nvim_set_hl(0, 'FugitiveTsAdd', { bg = diff_add.bg }) + vim.api.nvim_set_hl(0, 'FugitiveTsDelete', { bg = diff_delete.bg }) end return M diff --git a/spec/highlight_spec.lua b/spec/highlight_spec.lua index 38743f6..93c8784 100644 --- a/spec/highlight_spec.lua +++ b/spec/highlight_spec.lua @@ -7,6 +7,10 @@ describe('highlight', function() before_each(function() ns = vim.api.nvim_create_namespace('fugitive_ts_test') + local diff_add = vim.api.nvim_get_hl(0, { name = 'DiffAdd' }) + local diff_delete = vim.api.nvim_get_hl(0, { name = 'DiffDelete' }) + vim.api.nvim_set_hl(0, 'FugitiveTsAdd', { bg = diff_add.bg }) + vim.api.nvim_set_hl(0, 'FugitiveTsDelete', { bg = diff_delete.bg }) end) local function create_buffer(lines) @@ -318,7 +322,7 @@ describe('highlight', function() local extmarks = get_extmarks(bufnr) local has_diff_add = false for _, mark in ipairs(extmarks) do - if mark[4] and mark[4].line_hl_group == 'DiffAdd' then + if mark[4] and mark[4].line_hl_group == 'FugitiveTsAdd' then has_diff_add = true break end @@ -351,7 +355,7 @@ describe('highlight', function() local extmarks = get_extmarks(bufnr) local has_diff_delete = false for _, mark in ipairs(extmarks) do - if mark[4] and mark[4].line_hl_group == 'DiffDelete' then + if mark[4] and mark[4].line_hl_group == 'FugitiveTsDelete' then has_diff_delete = true break end @@ -516,7 +520,7 @@ describe('highlight', function() local extmarks = get_extmarks(bufnr) local has_diff_add = false for _, mark in ipairs(extmarks) do - if mark[4] and mark[4].line_hl_group == 'DiffAdd' then + if mark[4] and mark[4].line_hl_group == 'FugitiveTsAdd' then has_diff_add = true break end