rktjmp / lush.nvim

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

Converting lush colors to use with Kitty, Alacritty, AwesomeWM, etc #55

Closed ashincoder closed 3 years ago

ashincoder commented 3 years ago

Hello I was wondering how can I convert lush colors to use for terminals lke kitty and alacritty.

rktjmp commented 3 years ago

You need to access the theme via some lua interpreter and write the colors out.

If you're doing this outside of vim you will have to add lush and the theme to lua's package path.

Something like this

-- export-theme.lua

-- adjust lua package path so it can find both lush, and the theme.
package.path = package.path
    .. ";/path/to/lush.nvim/lua/?.lua"
    .. ";/path/to/theme/lua/?.lua"

local theme = require("lush_theme.theme_name") -- depends on your theme
                                               -- dir structure

local extracted = {
  bg = theme.Normal.bg, -- depending on use, you may need .hex
  fg = theme.Normal.fg, -- but generally it should be coerced for you.
  -- ... etc
}

for name, color in pairs(extracted) do
  print(string.format("%s='%s';", name, color))
end

$ lua export-theme.lua > theme.conf

If you're doing it inside vim, you can skip the package.path modification.

Lush itself should run in lua 5.1, 5.2, 5.3 and I think 5.4, but your own theme code may be limited to 5.1 depending on what you're doing. Most themes should be fine.

This means you can import lush and lush themes into something like AwesomeWM and use the values natively.

ashincoder commented 3 years ago

ok thx