Skip to content

Commit 9a6ee3d

Browse files
fix: Highglight application for termgui themes (#353)
closes #346
1 parent 29585a4 commit 9a6ee3d

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

lua/fff/file_renderer.lua

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,27 @@ function M.apply_highlights(item, ctx, item_idx, buf, ns_id, line_idx, line_cont
182182
if is_cursor then
183183
local base_hl = git_utils.get_border_highlight_selected(item.git_status)
184184
if base_hl and base_hl ~= '' then
185-
local border_fg = vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID(base_hl)), 'fg')
186-
local cursor_bg = vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID(ctx.config.hl.cursor)), 'bg')
187-
local temp_hl_name = 'FFFGitBorderSelected_' .. item_idx
188-
if border_fg ~= '' and cursor_bg ~= '' then
189-
vim.api.nvim_set_hl(0, temp_hl_name, { fg = border_fg, bg = cursor_bg })
185+
local base_id = vim.fn.synIDtrans(vim.fn.hlID(base_hl))
186+
local cursor_id = vim.fn.synIDtrans(vim.fn.hlID(ctx.config.hl.cursor))
187+
local border_fg_gui = vim.fn.synIDattr(base_id, 'fg', 'gui')
188+
local border_fg_cterm = vim.fn.synIDattr(base_id, 'fg', 'cterm')
189+
local cursor_bg_gui = vim.fn.synIDattr(cursor_id, 'bg', 'gui')
190+
local cursor_bg_cterm = vim.fn.synIDattr(cursor_id, 'bg', 'cterm')
191+
local has_gui = border_fg_gui ~= '' and cursor_bg_gui ~= ''
192+
local has_cterm = border_fg_cterm ~= '' and cursor_bg_cterm ~= ''
193+
194+
if has_gui or has_cterm then
195+
local temp_hl_name = 'FFFGitBorderSelected_' .. item_idx
196+
local hl_opts = {}
197+
if has_gui then
198+
hl_opts.fg = border_fg_gui
199+
hl_opts.bg = cursor_bg_gui
200+
end
201+
if has_cterm then
202+
hl_opts.ctermfg = tonumber(border_fg_cterm)
203+
hl_opts.ctermbg = tonumber(cursor_bg_cterm)
204+
end
205+
vim.api.nvim_set_hl(0, temp_hl_name, hl_opts)
190206
border_hl = temp_hl_name
191207
else
192208
border_hl = git_utils.get_border_highlight_selected(item.git_status)

0 commit comments

Comments
 (0)