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

Feature: Support transparent gutter via highlight group #1306

Closed
1 task done
scottmckendry opened this issue Jun 28, 2024 · 8 comments
Closed
1 task done

Feature: Support transparent gutter via highlight group #1306

scottmckendry opened this issue Jun 28, 2024 · 8 comments
Labels
feature request New feature

Comments

@scottmckendry
Copy link

Have you RTFM'd?

  • I have done proper research

Feature Request

I'm currently in the process of adding support for Fzf-lua to my colorscheme and noticed that setting the bg property of FzfLuaFzfGutter to "NONE" does not make it transparent. Setting it to a solid color works fine, however.

Is this something that could be supported in the future?

@scottmckendry scottmckendry added the feature request New feature label Jun 28, 2024
@ibhagwan
Copy link
Owner

ibhagwan commented Jun 28, 2024

Fzf runs in a neovim terminal, the gutter color needs to be translated into an ansi escape sequence and NONE has no color, while I could translate it manually to -1 it would be hacky (-1 is fzf specific).

Why don’t you set your fzf_colors = { ['gutter'] = '-1' }, if you wanted to do so without calling setup (e.g. in a color scheme) you can set it in vim.g.fzf_colors:
https://github.com/ibhagwan/fzf-lua?tab=readme-ov-file#fzf-colors

@scottmckendry
Copy link
Author

Thanks! I think I can make that work with the vim.g variable.

@ramojus
Copy link

ramojus commented Dec 29, 2024

This doesn't seem to be working anymore. Even if I set this color via command with :lua require'fzf-lua'.files({ hls={["gutter"] = "-1"} }), the gutter is still not transparent:
image

@ibhagwan
Copy link
Owner

This doesn't seem to be working anymore. Even if I set this color via command with :lua require'fzf-lua'.files({ hls={["gutter"] = "-1"} }), the gutter is still not transparent: image

Because you’re setting it in the wrong place, gutter should be under fzf_colors.

@ramojus
Copy link

ramojus commented Jan 1, 2025

Right, sorry.
So it does work with :lua require'fzf-lua'.files({ fzf_colors={["gutter"] = "-1"} }), but then all other fzf_colors (which I set through highlight groups) are back to their default. Same thing happens if I put this in my config:

require('fzf-lua').setup {
    fzf_colors = {
        ["gutter"] = "-1",
    }
}

And vim.g.fzf_colors = { ["gutter"] = "-1" } doesn't seem to have any affect.

The only way to achieve what I want is if I set all of the colors through setup (hl is my own module, so please ignore the specifics of that, but basically I'm reusing the highlight groups that I have already set):

require('fzf-lua').setup {
    fzf_colors = {
        ["fg"] = hl.get("FzfLuaNormal").fg.hex,
        ["bg"] = hl.get("FzfLuaNormal").bg.hex,
        ["fg+"] = hl.get("FzfLuaFzfCursorLine").fg.hex,
        ["bg+"] = hl.get("FzfLuaFzfCursorLine").bg.hex,
        ["hl+"] = hl.get("FzfLuaFzfMatch").fg.hex,
        -- ["border"] = hl.get("FzfLuaFzfBorder").fg.hex,
        ["scrollbar"] = hl.get("FzfLuaFzfScrollbar").fg.hex,
        ["separator"] = hl.get("FzfLuaFzfSeparator").fg.hex,
        ["gutter"] = "-1",
        ["header"] = hl.get("FzfLuaFzfHeader").fg.hex,
        ["info"] = colors.fg4.hex,
        ["pointer"] = hl.get("FzfLuaFzfPointer").fg.hex,
        ["marker"] = hl.get("FzfLuaFzfMarker").fg.hex,
        -- ["spinner"] = hl.get("FzfLuaFzfSpinner").fg.hex,
        ["prompt"] = hl.get("FzfLuaFzfPrompt").fg.hex,
        ["query"] = hl.get("FzfLuaFzfQuery").fg.hex,
    }
}

but as this is for a colorscheme, it feels a bit forced. I would prefer to only use highlight groups. Please also note, that in the example above, bg of FzfLuaNormal is "NONE" and unlike ["gutter"], ["bg"] stays transparent with this value.

So I guess I'm okay using the workaround above for now, but it would be nicer if setting FzfLuaFzfGutter to "NONE" worked.

@ibhagwan
Copy link
Owner

ibhagwan commented Jan 1, 2025

Set the first index to true and you’ll get both the generated theme and override:

require('fzf-lua').setup {
    fzf_colors = {
        true,  --  this
        ["gutter"] = "-1",
    }
}

This is mentioned in the fzf_colors part of the README under the default options, I should probably add it at the bottom fzf_colors part of the README too.

@ramojus
Copy link

ramojus commented Jan 4, 2025

That's nicer, thanks for your help!
I'm still a bit hesitant to use this. Would you perhaps be interested in a PR that would allow to just use a highlight group with "NONE" value?

@ibhagwan
Copy link
Owner

ibhagwan commented Jan 4, 2025

That's nicer, thanks for your help! I'm still a bit hesitant to use this. Would you perhaps be interested in a PR that would allow to just use a highlight group with "NONE" value?

I’m thinking a better option, if the resulting color is none set it to -1 (just for fzf_colors).

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

No branches or pull requests

3 participants