fix: ensure float highlights exists before use

This commit is contained in:
Akin Sowemimo 2022-07-04 08:25:08 +02:00
parent c94f414077
commit 6ea176907d
2 changed files with 7 additions and 5 deletions

View file

@ -47,7 +47,7 @@ local config = {
---Derive the highlights for a toggleterm and merge these with the user's preferences
---A few caveats must be noted. Since I link the normal and float border to the Normal
---highlight this has to be done carefully as if the user has speficied any Float highlights
---highlight this has to be done carefully as if the user has specified any Float highlights
---themselves merging will result in a mix of user highlights and the link key which is invalid
---so I check that they have not attempted to highlight these themselves. Also
---if they have chosen to shade the terminal then this takes priority over their own highlights
@ -57,8 +57,8 @@ local config = {
local function get_highlights(conf)
local user = conf.highlights
local defaults = {
NormalFloat = vim.F.if_nil(user.NormalFloat, { link = "Normal" }),
FloatBorder = vim.F.if_nil(user.FloatBorder, { link = "Normal" }),
NormalFloat = user.NormalFloat or { link = "Normal" },
FloatBorder = user.FloatBorder or { link = "Normal" },
StatusLine = { gui = "NONE" },
StatusLineNC = { cterm = "italic", gui = "NONE" },
}

View file

@ -101,8 +101,10 @@ function M.hl_term(term)
local name = constants.highlight_group_name_prefix .. id .. hl_group_name
local hi_target = fmt("%s:%s", hl_group_name, name)
local attrs = hls[hl_group_name]
attrs.default = true
colors.set_hl(name, attrs)
if attrs then
attrs.default = true
colors.set_hl(name, attrs)
end
return hi_target
end, hl_names)