Exporting color palette and lush spec in a single lua table #86
-
Hi, I was wondering if there's a metamethod magic I could apply to export a color palette and a lush spec in a single table. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
The lush spec itself is a table, so you should be able to do something like local colorscheme = require("my-lush-theme")
-- then either access the color, convert it to a string or get the hex value directly
local bg = colorscheme.Normal.bg
bg.darken(10) -- can still apply operators
bg.h -- or access h,s,l, anything values
local bg_hex = colorscheme.Normal.bg.hex -- get as hex string
local str = tostring(colorscheme.Normal.bg) -- anything tostring'ing will convert to hex automatically
local rgb = colorscheme.Normal.bg.rgb -- {r, g, b} table (just added, so you may need to git pull) If you want to store a normal table (or any other data), you can use the Lines 304 to 306 in 87e9039 Melange does this by storing the palette on an arbitrary group: Which is then accessible via You can also look at https://github.com/rktjmp/lush.nvim/blob/main/BUILD.md which lets you export your spec in any way you want. |
Beta Was this translation helpful? Give feedback.
-
I'll take a look at shipwright as I would like to export a palette for awesomewm |
Beta Was this translation helpful? Give feedback.
-
Here's what I was able to come up with 2022-04-13.14-44-15.mov |
Beta Was this translation helpful? Give feedback.
The lush spec itself is a table, so you should be able to do something like
If you want to store a normal table (or any other data), you can use the
lush
key which is retained in the spec: