Skip to content

Commit 4aeb383

Browse files
authored
fix(highlights): adds nil check to Normal group 'fg' to address #196 (#197)
1 parent 9d73cde commit 4aeb383

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lua/checkmate/highlights.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,20 @@ function M.clear_highlight_cache()
323323
end
324324

325325
function M.register_highlight_groups()
326+
local function normal_fg_or_nil()
327+
local normal_exists = vim.fn.hlexists("Normal") == 1
328+
if not normal_exists then
329+
log.fmt_warn("[highlights/register_highlight_groups] Missing 'Normal' hl. ")
330+
return nil
331+
end
332+
local hl = vim.api.nvim_get_hl(0, { name = "Normal", link = false })
333+
return hl and hl.fg or nil
334+
end
335+
326336
local highlights = {
327337
---this is used when we apply an extmark to override , e.g. setext headings
328338
---@type vim.api.keyset.highlight
329-
CheckmateNormal = { bold = false, force = true, nocombine = true, fg = "fg" },
339+
CheckmateNormal = { bold = false, force = true, nocombine = true, fg = normal_fg_or_nil() },
330340
}
331341

332342
-- generate highlight groups for each todo state

0 commit comments

Comments
 (0)