Skip to content

Commit

Permalink
fix(windows): redefine winhl on opacity update
Browse files Browse the repository at this point in the history
winhl in nightly now works by linking the highlights in a window local
namespace as opposed to directly pointing to the desired group. Since
links don't follow updates, the winhl must now be reset on each opacity
update.

This is a non-optimal solution as it now requires us to make an
vimscript call on every render but it is backwards compatible. When the
next version of NeoVim is released, we can switch to using window local
namespaces entirely.

See #123
  • Loading branch information
rcarriga committed Aug 24, 2022
1 parent 60bb6bf commit df6fc96
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lua/notify/windows/init.lua
Expand Up @@ -59,6 +59,11 @@ function WindowAnimator:push_pending(queue)
end
win_opts.noautocmd = true
local win = util.open_win(notif_buf, false, win_opts)
vim.fn.setwinvar(
win,
"&winhl",
"Normal:" .. notif_buf.highlights.body .. ",FloatBorder:" .. notif_buf.highlights.border
)
self.win_stages[win] = 2
self.win_states[win] = {}
self.notif_bufs[win] = notif_buf
Expand Down Expand Up @@ -242,7 +247,14 @@ function WindowAnimator:apply_updates()
for win, states in pairs(self.win_states) do
updated = true
if states.opacity then
self.notif_bufs[win].highlights:set_opacity(states.opacity.position)
local notif_buf = self.notif_bufs[win]
notif_buf.highlights:set_opacity(states.opacity.position)

vim.fn.setwinvar(
win,
"&winhl",
"Normal:" .. notif_buf.highlights.body .. ",FloatBorder:" .. notif_buf.highlights.border
)
end
local exists, conf = util.get_win_config(win)
if not exists then
Expand Down

0 comments on commit df6fc96

Please sign in to comment.