diff options
Diffstat (limited to 'runtime/lua/core/theme.lua')
| -rw-r--r-- | runtime/lua/core/theme.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/runtime/lua/core/theme.lua b/runtime/lua/core/theme.lua new file mode 100644 index 0000000..cead212 --- /dev/null +++ b/runtime/lua/core/theme.lua @@ -0,0 +1,34 @@ +local M = {} + +local function rgba(hex) + local h = hex:gsub("#", "") + if #h ~= 6 then + return 0, 0, 0, 255 + end + + local r = tonumber(h:sub(1, 2), 16) or 0 + local g = tonumber(h:sub(3, 4), 16) or 0 + local b = tonumber(h:sub(5, 6), 16) or 0 + return r, g, b, 255 +end + +local default_map = { + bg_top = "base00", + bg_bottom = "base01", + text = "base05", + cursor = "base08", + accent = "base09", +} + +function M.apply_base16(palette, color_map) + local map = color_map or default_map + for editor_color, base_key in pairs(map) do + local hex = palette[base_key] + if hex then + local r, g, b, a = rgba(hex) + editor.set_theme_color(editor_color, r, g, b, a) + end + end +end + +return M |
