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

Provide Transparency for yazi.nvim Floating Window #154

Open
Tahinli opened this issue Feb 5, 2025 · 7 comments
Open

Provide Transparency for yazi.nvim Floating Window #154

Tahinli opened this issue Feb 5, 2025 · 7 comments

Comments

@Tahinli
Copy link

Tahinli commented Feb 5, 2025

Hi,

Firstly thanks for this theme.

Can you provide transparent background for floating windows.
As you can see I have floating window as a file manager which is yazi and there is a bit ugly border around here. It's colors are assigned by nvim theme, right now it's everforest. Definitely it's not a bug but this is the reason why I'm here.

Image

@antoineco
Copy link
Collaborator

antoineco commented Feb 5, 2025

Thanks for the report, I'm not familiar with Yazi but it does look like a bug. Could you please share what everforest options are set in your config?

@Tahinli
Copy link
Author

Tahinli commented Feb 5, 2025

return {
    "sainnhe/everforest",
    config = function()
        vim.g.everforest_transparent_background = 2
        vim.g.everforest_float_style = "dim"
        vim.g.everforest_diagnostic_text_highlight = 1
        vim.g.everforest_diagnostic_line_highlight = 1
        vim.g.everforest_diagnostic_virtual_text = "highlighted"
        vim.g.everforest_dim_inactive_windows = 1
        vim.g.everforest_ui_contrast = "high"
        vim.g.everforest_better_performans = 1
        vim.cmd.colorscheme("everforest")
    end
}

@antoineco
Copy link
Collaborator

antoineco commented Feb 5, 2025

I had a quick look at the highlight groups and I understand the problem: floating windows aren't affected by transparency, otherwise they would blend with the underlying window(s) and become unreadable.

Wouldn't it be a better solution to style the Yazi background using a plain color from the Everforest palette, to make it look like other floating windows? You can try with :highlight! link YaziFloat NormalFloat.

If you really want to keep Yazi transparent, could you please try calling :highlight! YaziFloatBorder guifg=#859289 guibg=NONE, and report how it looks?

@Tahinli
Copy link
Author

Tahinli commented Feb 6, 2025

Wouldn't it be a better solution to style the Yazi background using a plain color from the Everforest palette, to make it look like other floating windows? You can try with :highlight! link YaziFloat NormalFloat.

Image

If you really want to keep Yazi transparent, could you please try calling :highlight! YaziFloatBorder guifg=#859289 guibg=NONE, and report how it looks?

Image

Worked as you said.

Sorry I'm new on lua and nvim how can I make transparent default ?

@antoineco
Copy link
Collaborator

antoineco commented Feb 7, 2025

Your Neovim distribution might offer facilities for overriding highlights of particular colorschemes (AstroVim does, I'm not sure about LazyVim). The ones that do implement that feature using an autocommand, similarly to what's described in Everforest's documentation:

Or in Neovim (Lua configuration):
>
vim.api.nvim_create_autocmd('ColorScheme', {
group = vim.api.nvim_create_augroup('custom_highlights_everforest', {}),
pattern = 'everforest',
callback = function()

In your case, you could add this to your init.lua file, before plugins are loaded:

vim.api.nvim_create_autocmd('ColorScheme', {
    group = vim.api.nvim_create_augroup('custom_highlights_everforest', {}),
    pattern = 'everforest',
    callback = function()
        -- Yazi borders. Match background of Yazi window, which is transparent.
        vim.api.nvim_set_hl(0, 'YaziFloatBorder', { link = 'Grey' })
    end
})

We could (and maybe should) add support for yazi.nvim to the colorscheme. If we do, we'll have to be consistent with other plugins that use floating windows and adopt the first style I suggested rather than the second (NormalFloat background).

@antoineco antoineco changed the title [Feature Request] Provide Transparency for Floating Window Provide Transparency for yazi.nvim Floating Window Feb 7, 2025
@Tahinli
Copy link
Author

Tahinli commented Feb 7, 2025

Thanks the command you provided works.

I'm not sure if you need any inspiration but catpuccin also able to provide full transparency when I set the option transparent_background = true.

I don't know maybe this situation can give some ideas to you.

Thanks again. You already solved mu issue but since I think you want to follow for more. I'm not going to close this issue.

Furthermore I use also blink for code completion and they are also not transparent. Since catpuccin can make transparent it too without any command. I don't know if you need to adapt everforest for every plugin or there is a general way.

Image

Image

@antoineco
Copy link
Collaborator

The fact that we don't make floating windows transparent was a design decision. I'm not sure whether we want to revisit that, for instance by introducing everforest_transparent_background = 3. Meanwhile you can try to clear a few more highlight groups by adding these lines to your everforest autocommand:

-- For completion menus like blink.cmp.
vim.api.nvim_set_hl(0, 'Pmenu', {})
-- For regular floating windows.
vim.api.nvim_set_hl(0, 'NormalFloat', {})

In Vimscript (e.g. on the command line), you can clear a highlight group with hi clear <Name>, for instance :hi clear BlinkCmpMenu for blink.cmp's background specifically. It might take a few attempts before you find all the highlight groups that have a background.

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

No branches or pull requests

2 participants