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