Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check to work with transparent themes #71

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

gingkapls
Copy link

@gingkapls gingkapls commented Jun 11, 2021

Right now limelight throws an error about not being able to calculate bg color because of ctermbg value of Normal highlight group being set to none to allow transparency in terminals. Setting the bg value for dim coefficient to 0 solves this.

This PR adds a check to see if ctermbg is set to none (used in themes with transparent backgrounds) and changes the bg value of dim coefficient to 0 as a fix, otherwise the plugin works as before.

Now both transparent and non-transparent themes work properly
@NSAntoine
Copy link

approved

autoload/limelight.vim Outdated Show resolved Hide resolved
@gingkapls gingkapls requested a review from junegunn March 16, 2022 11:33
Copy link
Owner

@junegunn junegunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which color scheme should I test this with?

@gingkapls
Copy link
Author

Which color scheme should I test this with?

I tested this with a modified base16-vim scheme where I had replaced the Normal highlight bg with none.

You can use any color scheme, and run :hi Normal ctermbg=none guibg=none before calling Limelight to test it.

@junegunn
Copy link
Owner

You can use any color scheme, and run :hi Normal ctermbg=none guibg=none before calling Limelight to test it.

Getting this error:

E254: Cannot allocate color none

Fixes calculating the bg for `Normal` highlight group depending on the ctermbg value
@gingkapls
Copy link
Author

You can use any color scheme, and run :hi Normal ctermbg=none guibg=none before calling Limelight to test it.

Getting this error:

E254: Cannot allocate color none

Oh, I'm so sorry!
I had been trying this plugin on neovim, and could not reproduce this error. Apparently they handle the command differently?
Tried it on vim again and the :hi Normal ctermbg=none guibg=none gave me the same error you got.

This time I tried it on barebones vim, you can select the darkblue preinstalled colors scheme, and after that only change :hi Normal ctermbg=none and you'll be good to go!

Also, I noticed that that Limelight was not able to calculate the dim coefficient with the ternary operator patch. Tweaking the logic fixed that for me so I pushed that to master.
Please try it again and let me know if it works now!

@gingkapls gingkapls requested a review from junegunn March 23, 2022 05:48
@junegunn
Copy link
Owner

junegunn commented Mar 23, 2022

I don't think the patch is correct. After applying your patch, Limelight stops working with any of my color schemes. (e.g. seoul256, Tomorrow, etc.)

Unsupported color scheme. g:limelight_conceal_ctermfg required.

Note that I'm using &termguicolors.

@gingkapls
Copy link
Author

Hmm, &termguicolors uses gui colors for highlights instead of cterm ones, probably that's what breaks it.
I'll see how to fix it and come back to this.

@@ -138,7 +138,7 @@ function! s:dim(coeff)
let synid = synIDtrans(hlID('Normal'))
let fg = synIDattr(synid, 'fg#')
let bg = synIDattr(synid, 'bg#')
let bg = bg == 'none' ? 0 : bg
let bg = bg == 'none' ? bg : 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't make sense to me. Why are we discarding a validbg value and only keeping none?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants