limelight.vim icon indicating copy to clipboard operation
limelight.vim copied to clipboard

Add a check to work with transparent themes

Open gingkapls opened this issue 3 years ago • 6 comments

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.

gingkapls avatar Jun 11 '21 06:06 gingkapls

approved

NSAntoine avatar Jan 14 '22 08:01 NSAntoine

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.

gingkapls avatar Mar 16 '22 19:03 gingkapls

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

junegunn avatar Mar 17 '22 02:03 junegunn

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 avatar Mar 17 '22 06:03 gingkapls

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.

junegunn avatar Mar 23 '22 06:03 junegunn

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.

gingkapls avatar Mar 23 '22 08:03 gingkapls