From cebb280fe546190e55e071b6adbf37cd47950f34 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Mon, 11 May 2026 15:07:55 -0500 Subject: initial commit --- runtime/lua/core/theme.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 runtime/lua/core/theme.lua (limited to 'runtime/lua/core/theme.lua') 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 -- cgit v1.3.1