folke / twilight.nvim

🌅 Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing using TreeSitter.
Apache License 2.0
1.24k stars 21 forks source link

Background is black when using guibg=NONE #15

Closed TheSmallTeaBoi closed 1 year ago

TheSmallTeaBoi commented 3 years ago

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)

axieax commented 2 years ago

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

matdexir commented 2 years ago

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:

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.

BerkinAKKAYA commented 2 years ago

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
axieax commented 2 years ago

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)?

evantravers commented 2 years ago

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