cideM / yui

A minimal Vim/Neovim color scheme inspired by Dieter Rams
MIT License
135 stars 7 forks source link

Improve Lightline colors #38

Closed cideM closed 1 year ago

cideM commented 1 year ago

The current lightline colors are way too dark. This commit generally lightens the colors, so that we can then darken them as we go from center to the sides.

First, we find the StatusLine guibg and lighten it a bit.

Then we define 5 shades, from middle to sides. The shades are based on the base colors, which are StatusLine (lightened) and c.black1.

This basically implements what I already had in https://github.com/cideM/yui/pull/32#issuecomment-1511035457

Screenshot 2023-04-28 at 11 08 19
mambusskruj commented 1 year ago

I wonder if we need to separate last right sided block. I mean, lightline do it by design, but should we really? Both apply to cursor navigation through the file.

cideM commented 1 year ago

Good point

cideM commented 1 year ago

I've made a few more modifications. Inactive now uses base FG and base BG. It's still easy to recognize by the fact that it doesn't have any shades.

An alternative would be to lighten all the shades for inactive? I'll experiment with this.

I also removed the additional separation of colors on the right side.

Screenshot 2023-04-28 at 14 54 28 Screenshot 2023-04-28 at 14 54 32

mambusskruj commented 1 year ago

Inactive now uses base FG and base BG. It's still easy to recognize by the fact that it doesn't have any shades.

Personally I love this one, since inactive could logically mean that on that window plugin is inactive, so no active features, and no coloring either.

cideM commented 1 year ago

Cleaned up the code a bit. We now get the FG and BG base colors from StatusLine. Then we lighten the base colors a bit, so that we can gradually darken them again, without it getting too dark. I removed the additional distinction for line position on the right.

This is the relevant part of the code.

-- higher index = darker, meaning lightline components towards the side of the
-- statusline should use higher indexes
local lightline_bg_shades = {}
local lightline_fg_shades = {}

-- Find StatusLine color
for _, block in ipairs(M.groups) do
    for _, highlight in ipairs(block.groups) do
        if type(highlight) == "table" and highlight.name == "StatusLine" then
            -- StatusLine uses "reverse", hence the bg = fg
            local base_bg = highlight.guifg
            local base_fg = highlight.guibg

            -- Since we darken the background towards the sides, we should lighten
            -- the StatusLine color a bit, otherwise it'll get very dark towards
            -- the sides
            for i, factor in ipairs({ 5, 0, -5 }) do
                lightline_bg_shades[i] = lightness(base_bg, factor)
                lightline_fg_shades[i] = lightness(base_fg, factor)
            end
            break
        end
    end
end

local lightline_bg_shades_inactive = {
    lightline_bg_shades[1],
    lightline_bg_shades[1],
    lightline_bg_shades[1],
}
local lightline_fg_shades_inactive = {
    lightness(lightline_fg_shades[1], 15),
    lightness(lightline_fg_shades[1], 15),
    lightness(lightline_fg_shades[1], 15),
}

Screenshot 2023-04-28 at 15 31 21