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

Not dimming anything

nicolimo86 opened this issue · comments

Hi,
it seems that twilight is not dimming the text that I'm not editing. I have the impression that the plugin is not doing anything (see screenshot).

INFO:
neovim: v0.5.1
plugins:

Plug 'folke/zen-mode.nvim'
Plug 'folke/twilight.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}

The command :PlugInstall has been runned succesfully and neovim was restarted.
Zen-mode and twilight are configure as follow:
image

I'm trying to edit a bash script while being in zen-mode:

image

what am I doing wrong?

I am experiencing this same issue

Can you see if using another colorscheme fixes it?

I've just became aware that not all colorschemes have the tree-sitter support, including mine. I haven't tried yet to install a diffirent colorscheme with such TS support...but I suspect that the issue should be related to that. Feel free to close the issue.

I have been experiencing the same issue. I don't use a colourscheme, I just use the default theme that ships with neovim.

If there is a requirement to use a specific colourscheme that is compatible with twilight, then it might be worth indicating this in the documentation and giving some examples of known colourschemes that work well with the plugin.

Also, is it not possible for this to work with the default scheme at all?

It should work with any color scheme, but something might go wrong with some colorschemes.

Can you give me the output for:

:hi Twilight
:hi Normal

The result for the 2 commands is the following:

:hi Twilight --> E411: highlight group not found: Twilight
:hi Normal --> Normal         xxx ctermfg=223 ctermbg=235 guifg=#ebdbb2 guibg=#282828

Did you run twilight setup? The colorgroup should be defined

I think I know why it's not working for you. You probably change your colorscheme after twilight setup. That would clear any hl groups set by Twilight.

also had this issue, and can confirm that it works after moving twilight setup towards the top of my config. before :hi Twilight didn't find the group until after :Twilight was run, but at that point the highlight group was empty.

@folke Thanks for the troubleshooting steps. Unfortunately the issue is still present.

Output of :hi Twilight:

:hi Twilight
Twilight       xxx guifg=#404040 guibg=#000000

Output of :hi Normal:

:hi Normal
Normal         xxx cleared

Some additional context:

  • Nvim version is 6.0
  • Terminals tested are Terminal.app on macOS Big Sur 11.6.1 & Terminal on Chrome OS (Debian container)
  • Nvim config handled via init.lua and is completely Lua based
  • Config structure for neovim can be found here
  • Your other plugin, Zenmode, has also been installed
  • Twilight plugin setup occurs before any other options are set
  • No colourscheme is set in this config, the default neovim theme is used

Hopefully that helps with tracking this bug down! Please let me know if there's any other information I can provide and I'll be more than happy to assist.

I've encountered the same issue as @brotherkaif (same neovim version, same issue, just on Manjaro/KDE). But I found the cause of the issue on my end:
Turns out that I didn't have termguicolors enabled in my config. (I've recently switched to a neovim-config repo to build my own configs around...) After I enabled the vim-option and reopened neovim, Twilight worked as intended again.

I hope this works for Kaif, too. Maybe this deserves a mention in the requirements-section of the README, @folke?

Turns out that I didn't have termguicolors enabled in my config.
I hope this works for Kaif, too. Maybe this deserves a mention in the requirements-section of the README, @folke?

in my opinion that's not a good move because it's not really a requirement. termguicolors is only used if it's enabled, like you said, but also only if cterm isn't set. for example, i use hi Twilight ctermfg=8 and it works as expected. a better change would be adding a ctermfg option to the highlight definition so termguicolors doesn't need to be enabled for console users.

Fair enough, I'm not really partial to either option, so I'll defer to the maintainer. :)

Hi, I had the same issue and basically the same situation as @brotherkaif, and setting hi Twilight ctermfg=8 fix the problem for me! (termguicolors are not set). Tnx @lilibyte for mentioning it and everyone else for investigating the problem.

Hi everyone, I have tested out the fix mentioned by @lilibyte and @yistarostin and can confirm that this has resolved the issue.

Is this something that should be considered a bug (i.e. should the plugin attempt to set hi Twilight ctermfg=8 itself? Or should this be an update to the documentation and considered as user configuration?

Either way, setting hi Twilight ctermfg=8 has fixed the problem. Thanks everyone for the help :-)

Turns out that I didn't have termguicolors enabled in my config.
I hope this works for Kaif, too. Maybe this deserves a mention in the requirements-section of the README, @folke?

in my opinion that's not a good move because it's not really a requirement. termguicolors is only used if it's enabled, like you said, but also only if cterm isn't set. for example, i use hi Twilight ctermfg=8 and it works as expected. a better change would be adding a ctermfg option to the highlight definition so termguicolors doesn't need to be enabled for console users.

I confirm this fixed the issue for me. Thanks for the hint!