Skip to content

Add a check to work with transparent themes #71

Open
notginned wants to merge 5 commits intojunegunn:masterfrom
notginned:master
Open

Add a check to work with transparent themes #71
notginned wants to merge 5 commits intojunegunn:masterfrom
notginned:master

Conversation

@notginned
Copy link
Copy Markdown

@notginned notginned 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
Copy Markdown

approved

@notginned notginned requested a review from junegunn March 16, 2022 11:33
Copy link
Copy Markdown
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?

@notginned
Copy link
Copy Markdown
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
Copy Markdown
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
@notginned
Copy link
Copy Markdown
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!

@notginned notginned requested a review from junegunn March 23, 2022 05:48
@junegunn
Copy link
Copy Markdown
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.

@notginned
Copy link
Copy Markdown
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.

let fg = synIDattr(synid, 'fg#')
let bg = synIDattr(synid, 'bg#')
let bg = bg == 'none' ? 0 : bg
let bg = bg == 'none' ? bg : 0
Copy link
Copy Markdown
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