Skip to content

Commit 61280b5

Browse files
committed
fix: highlight themes not being honored
Fixes #376
1 parent 4a557e7 commit 61280b5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lua/copilot/highlight.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ local links = {
1111
}
1212

1313
function mod.setup()
14-
for from_group, to_group in pairs(links) do
15-
vim.api.nvim_command("highlight default link " .. from_group .. " " .. to_group)
16-
end
14+
-- Some environments will load themes after plugins (like ChadNv) so we do it as late as possible
15+
vim.schedule(function()
16+
vim.print("Setting up copilot highlight groups")
17+
for from_group, to_group in pairs(links) do
18+
local ok, existing = pcall(vim.api.nvim_get_hl, 0, { name = from_group })
19+
if not ok or vim.tbl_isempty(existing) then
20+
vim.api.nvim_set_hl(0, from_group, { link = to_group })
21+
end
22+
end
23+
end)
1724
end
1825

1926
return mod

0 commit comments

Comments
 (0)