rktjmp / lush.nvim

Create Neovim themes with real-time feedback, export anywhere.
MIT License
1.49k stars 47 forks source link

Background transparency #38

Closed Deep-Six closed 3 years ago

Deep-Six commented 3 years ago

Hello, I'm working on a pywal based theme, which ingesting the pywal colors from ~/.cache/was/colors and thanks working great. However, I'm unable to get the background to be transparent. Also is there any facility to reapply lush based on an event? Currently I have to rerun Lushify when I change a background.

rktjmp commented 3 years ago

I'm working on a pywal based theme, which ingesting the pywal colors from ~/.cache/was/colors and thanks working great. However, I'm unable to get the background to be transparent.

Generally that's dependent on the terminal and set separately I think?

Also is there any facility to reapply lush based on an event? Currently I have to rerun Lushify when I change a background.

You mean from an external-to-vim event? I think you can hook into nvim via it's RPC system and basically use that to tell lush to re-run (or rather, just tell vim to reload it's colorscheme). I'm not sure how complicated that would be though, depends on what's changing your wallpaper and your language/msgpack library.

Another option would be making a small plugin that watches a file for changes and executes a command when they change. I might look at making that actually.

rktjmp commented 3 years ago

Here is a very basic watcher plugin:

https://github.com/rktjmp/fwatch.nvim

The API for that plugin might change as I think about it more and it probably has a bug or two, but it should let you at least try the idea.

You need to make your background change effect a file somehow.

rktjmp commented 3 years ago

In your case you're probably doing something like:

lua << EOF
local fwatch = require('fwatch')

fwatch.watch("/home/deepsix/.config/feh_config_file_or_whatever", "colorscheme my_scheme")
EOF

?

Deep-Six commented 3 years ago

@rktjmp I've published my really rough (but working) pywal based theme, I am definitely open to suggestions, this is my first Lua program, and I really don't consider myself a developer per se. I'm sure you can improve upon it, more importantly I think long term basing it on pywal might not be the greatest idea because it often times doesn't extract more than 8 colours for a pallete.

I am still unable to get lightline or transparency to work..

Code is here:

https://github.com/Deep-Six/pywal-lush

rktjmp commented 3 years ago

That's actually pretty neat if not somewhat unpredictable.

I managed to get the auto application working with fwatch, but you have to put a small timer to avoid trying to generate the scheme from a half updated file.

I just put this after where I set my colorscheme

lua << EOF
fwatch = require('fwatch')
fwatch.watch("/home/soup/.cache/wal/colors", {
  -- when file changes
  on_event = function()
    -- wait 200ms then
    vim.defer_fn(function()
      -- reapply the colorscheme
      vim.cmd("colorscheme pywal")
    end, 200)
  end
})
EOF

Lightline is pretty awkward. You can see in the examples a bit on how to get it to work, it involves basically building a separate dictionary for lightline and then turning it off and on again.

Not sure if all status lines are like that or not, I think lualine just uses regular highlight groups so lush should just be able to set them no problem.

The transparency (as in, see wallpaper through vim) stuff will be per-terminal and not controlled by lush or vim.

Deep-Six commented 3 years ago

I managed to get lightline working, it was a matter of finding the right theme name to not deviate from your original methodology. I'm getting to rework it when I have time. I might take a look at lualine for ease of use. It is unpredictable but it actually by and large works pretty well. The real problem only happens when you have an image that doesn't have the colour diversity needed. Thanks for lush it was super cool to play with!

On Mon., May 3, 2021, 08:37 Oliver Marriott, @.***> wrote:

That's actually pretty neat if not somewhat unpredictable.

I managed to get the auto application working with fwatch, but you have to put a small timer to avoid trying to generate the scheme from a half updated file.

I just put this after where I set my colorscheme

lua << EOF fwatch = require('fwatch') fwatch.watch("/home/soup/.cache/wal/colors", { -- when file changes on_event = function() -- wait 200ms then vim.defer_fn(function() -- reapply the colorscheme vim.cmd("colorscheme pywal") end, 200) end }) EOF

Lightline is pretty awkward. You can see in the examples a bit on how to get it to work, it involves basically building a separate dictionary for lightline and then turning it off and on again.

Not sure if all status lines are like that or not, I think lualine just uses regular highlight groups so lush should just be able to set them no problem.

The transparency (as in, see wallpaper through vim) stuff will be per-terminal and not controlled by lush or vim.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rktjmp/lush.nvim/issues/38#issuecomment-831264402, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFR63V6J55GQQUNTXBHOWZDTL2RJJANCNFSM43QPZ5NQ .

Deep-Six commented 3 years ago

@rktjmp the watch works perfect making this totally dynamic! Thanks!

Davincible commented 3 years ago

Stumbled upon this thread after I found your pywal lush theme and modified to work with wpgtk, and was looking for dynamic reloading. Thanks a lot to both of you for your work

Davincible commented 3 years ago

Since the issue title is still background transparency, I am experiencing the following; with some wallpapers (and associated color scheme) my vim background is non-existent (as desired), but with some, there is a background. I'm not sure what's causing this, do you have any idea how I can make them all transparent?

image image

rktjmp commented 3 years ago

Possibly pywal/wpgtk sets something funny depending on what the background is? Sounds weird though.

Does it persist if you re-open the terminal? It may be something like compiz/picom/whatever acting up.

That sporadic strip down the right is from the ColorColumn group, see :h colorcolumn for info on disabling it.

Actually, the ColorColumn seems like it's never being blended, maybe because it's so dark. I wonder if the term/compositor has trouble mixing dark colours and some wallpapers just have darker backgrounds?

Davincible commented 3 years ago

The background colors do change per wallpaper, but are all a slightly different shade of black/gray. Re-opening the terminal doesn't change anything. What's funny is that only with 3 specific wallpapers I always have a transparent background, with the rest I don't.

Before migrating over to lua, I used the native .vim theme for pywal/wpgtk, and there I had no problems. However then I was also in 8 bit color mode, this is 24 bit color mode.

The color column is intentional yeah

Davincible commented 3 years ago

Okay so its probaby because a background is explicitly set on all highlight groups. If I remove the bg= call from a specific highlight group, that group gets transparent.

Edit: after removing all bg = color1 in my case everything is transparent. I do agree this is probably only necessary because picom doesn't mix them properly.

Deep-Six commented 3 years ago

Hey everyone, Credit really goes to Oliver, he did the hard work. This was my first (and so far only) foray into Lua, so by all means if you have improvements please let me know! Let me know if you got background transparency working, this was something I didn't fuss with too much about.

Thanks, Jayson

On Sun, 20 Jun 2021 at 15:20, David Brouwer @.***> wrote:

Okay so its probaby because a background is explicitly set on all highlight groups. If I remove the bg= call from a specific highlight group, that group gets transparent.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rktjmp/lush.nvim/issues/38#issuecomment-864619130, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFR63V6XUO6JEGAIFZ6MDO3TTZSSPANCNFSM43QPZ5NQ .

Davincible commented 3 years ago

Background works perfectly now, after deleting all explicit bg = color definitions for right highlight groups image

Deep-Six commented 3 years ago

Can you submit a PR?

Thanks, Jayson

On Mon, 21 Jun 2021 at 03:08, David Brouwer @.***> wrote:

Background works perfectly now, after deleting all explicit bg = color definitions for right highlight groups [image: image] https://user-images.githubusercontent.com/25869544/122745346-3109a400-d289-11eb-927c-e30e77c1e5f4.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rktjmp/lush.nvim/issues/38#issuecomment-864909350, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFR63V6TNMCU2EMDGYL5RKLTT4FSHANCNFSM43QPZ5NQ .

Davincible commented 3 years ago

Just run :%s/ bg = color1,//g << that's all I've done to solve the the background issue

rktjmp commented 3 years ago

Closing this as it seems to be sorted out.