Skip to content

Commit

Permalink
fix: set extmark prio to 10000 to prevent other plugins to bleed thro…
Browse files Browse the repository at this point in the history
…ugh the dimming. Fixes #4
  • Loading branch information
folke committed Aug 5, 2021
1 parent 35b0c01 commit 0ac66e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/twilight/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function M.colors()
local normal = util.get_hl("Normal")
local bg = (normal and normal.background) or "#000000"
local dimmed = util.blend(fg, bg, M.options.dimming.alpha)
vim.cmd("highlight! def Twilight guifg=" .. dimmed)
vim.cmd("highlight! def Twilight guifg=" .. dimmed .. " guibg=" .. bg)
end

M.setup()
Expand Down
12 changes: 11 additions & 1 deletion lua/twilight/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,18 @@ function M.clear(buf, from, to)
vim.api.nvim_buf_clear_namespace(buf, ns, from, to)
end

-- TODO: fooo
function M.dim(buf, lnum)
vim.api.nvim_buf_add_highlight(buf, ns, "Twilight", lnum, 0, -1)
-- use extmarks directly so we can set the priority
-- do a pcall instead to prevent spurious errors at the end of the doc
pcall(vim.api.nvim_buf_set_extmark, buf, ns, lnum, 0, {
end_line = lnum + 1,
end_col = 0,
hl_group = "Twilight",
hl_eol = true,
priority = 10000,
})
-- vim.api.nvim_buf_add_highlight(buf, ns, "Twilight", lnum, 0, -1)
end

function M.range(node)
Expand Down

0 comments on commit 0ac66e8

Please sign in to comment.