rktjmp / lush.nvim

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

Bug with Hex to HSL? #151

Closed guilhermeprokisch closed 4 weeks ago

guilhermeprokisch commented 4 weeks ago

Hello there,

When I try to run a minium example setup using Lazyvim I've got a error when loading my theme. It was not loading at all.

-- In cool_name/lua/lush_theme/cool_name.lua

-- require lush
local lush = require("lush")
local hsl = lush.hsl

-- lush() will parse the spec and
-- return a table containing all color information.
-- We return it for use in other files.
return lush(function()
    return {
        -- Define Vim's Normal highlight group.
        -- You can provide values with hsl/hsluv or anything that responds to `tostring`
        Normal({ bg = hsl(208, 90, 30), fg = "#A3CFF5" }),

        -- Make whitespace slightly darker than normal.
        -- you must define Normal before deriving from it.
        Whitespace({ fg = Normal.fg.darken(40) }),

        -- Make comments look the same as whitespace, but with italic text
        -- Comment({ Whitespace, gui = "italic" }),

        -- Clear all highlighting for CursorLine
        -- CursorLine({}),
    }
end)

After some debug I was able to load it when replacing the fg = "#A3CFF5" for a hsl definition. It's supposed to work like that in or missing a hsl("A3CFF5") in this example?

https://github.com/rktjmp/lush.nvim/blob/6a254139d077ad53be7e4f3602c8da0c84447fd9/CREATE.md?plain=1#L101

rktjmp commented 4 weeks ago

It should indeed be hsl("#A3CFF5"), as the string type needs to be encapsulated in something smarter so the call to Normal.fg.darken resolves.

I think most people just go straight to editing the group dump in the template file or copying from :RunLushTutorial so the errors been missed.

rktjmp commented 4 weeks ago

Fixed in 3a50b41e4501f130d886a218f7c65ef6687e4504, sorry about the lost time on your end :disappointed:.