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

Not dimming anything #19

Closed nicolimo86 closed 2 years ago

nicolimo86 commented 2 years ago

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?

adlrwbr commented 2 years ago

I am experiencing this same issue

folke commented 2 years ago

Can you see if using another colorscheme fixes it?

nicolimo86 commented 2 years ago

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.

brotherkaif commented 2 years ago

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?

folke commented 2 years ago

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

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

Did you run twilight setup? The colorgroup should be defined

folke commented 2 years ago

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.

lilibyte commented 2 years ago

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.

brotherkaif commented 2 years ago

@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:

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.

pflakus commented 2 years ago

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?

lilibyte commented 2 years ago

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.

pflakus commented 2 years ago

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

yistarostin commented 2 years ago

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.

brotherkaif commented 2 years ago

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

nicolimo86 commented 2 years ago

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!