Skip to content

Commit

Permalink
fix: fix backwards compatibility with neovim v0.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Jul 17, 2024
1 parent 235f43b commit 1e46a32
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lua/astroui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ end
---@param fallback? table The fallback highlight properties
---@return table properties # the highlight group properties
function M.get_hlgroup(name, fallback)
local hl = vim.api.nvim_get_hl(0, { name = name, link = false, create = false })
if not vim.tbl_isempty(hl) then
if not hl.fg then hl.fg = "NONE" end
if not hl.bg then hl.bg = "NONE" end
if hl.reverse then
hl.fg, hl.bg, hl.reverse = hl.bg, hl.fg, nil
if vim.fn.hlexists(name) == 1 then
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
if not vim.tbl_isempty(hl) then
if not hl.fg then hl.fg = "NONE" end
if not hl.bg then hl.bg = "NONE" end
if hl.reverse then
hl.fg, hl.bg, hl.reverse = hl.bg, hl.fg, nil
end
return hl
end
return hl
end
return fallback or {}
end
Expand Down

0 comments on commit 1e46a32

Please sign in to comment.