Skip to content

Commit 1e46a32

Browse files
committed
fix: fix backwards compatibility with neovim v0.9+
1 parent 235f43b commit 1e46a32

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lua/astroui/init.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ end
4444
---@param fallback? table The fallback highlight properties
4545
---@return table properties # the highlight group properties
4646
function M.get_hlgroup(name, fallback)
47-
local hl = vim.api.nvim_get_hl(0, { name = name, link = false, create = false })
48-
if not vim.tbl_isempty(hl) then
49-
if not hl.fg then hl.fg = "NONE" end
50-
if not hl.bg then hl.bg = "NONE" end
51-
if hl.reverse then
52-
hl.fg, hl.bg, hl.reverse = hl.bg, hl.fg, nil
47+
if vim.fn.hlexists(name) == 1 then
48+
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
49+
if not vim.tbl_isempty(hl) then
50+
if not hl.fg then hl.fg = "NONE" end
51+
if not hl.bg then hl.bg = "NONE" end
52+
if hl.reverse then
53+
hl.fg, hl.bg, hl.reverse = hl.bg, hl.fg, nil
54+
end
55+
return hl
5356
end
54-
return hl
5557
end
5658
return fallback or {}
5759
end

0 commit comments

Comments
 (0)