folke / twilight.nvim

🌅 Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing using TreeSitter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Background is black when using guibg=NONE

TheSmallTeaBoi opened this issue · comments

This is how it looks without guibg=NONE:
image
and here's how it looks with it:
image

(I use this option to set vim's bg to my terminal's, in case there's a better way of doing this)

Having the same issue here. Is there a way to ignore background colour and only adjust/dim treesitter syntax highlighting?

Hi Guys, I found a little workaround/hack that only requires 4 lines of lua code.

local ok, hl = pcall(vim.api.nvim_get_hl_by_name, "Normal", true)
 if hl["background"] == nil then
   bg = "NONE"
end

The issue lies with config.lua where the background defaults to #000000 whenever the highlighting for the background is set to NONE.
So, if you want it to work properly you have to ensure that guibg=NONE.
If you want to use my hack:

  • Find where the twilight source code is on your machine.
  • Add the snippet of code I wrote to twilight.nvim/lua/twilight/config.lua

2021-09-03-07-50-15_1920x1080

VOILA!

2021-09-03-08-10-14_1920x1080

Note that this is only a hack(which may result in bugs) and hopefully the maintainer finds a proper way of solving this issue.

Setting guibg to NONE at the end of the function M.colors() fixes it as well.

-- twilight.nvim/lua/twilight/config.lua

function M.colors()
  ...

  vim.cmd("highlight! def Twilight guifg=" .. dimmed .. " guibg=NONE")
end

Hello @folke sorry for the bump, but could we get some updates on this on the repo (potentially a merge request/commit that resolves this)?

I just started seeing this… I think my colorscheme adjusted the way it calculates background.