Skip to content

Commit

Permalink
feat: save base_30 variables to file
Browse files Browse the repository at this point in the history
now users can directly access the color variables outside of hl_add/hl_override, dofile(vim.g.base46_cache .. "colors")
  • Loading branch information
siduck committed Sep 1, 2024
1 parent 35785f8 commit e9d2562
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lua/base46/color_vars.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local opts = require("nvconfig").base46
local str = ""
local colors = require("base46.themes." .. opts.theme).base_30

for name, hex in pairs(colors) do
str = str .. name .. "='" .. hex
str = str .. "',"
end

str = "return {" .. str .. "}"

return str
2 changes: 1 addition & 1 deletion lua/base46/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ M.turn_str_to_color = function(tb)
if valtype == "string" and val:sub(1, 1) ~= "#" and val ~= "none" and val ~= "NONE" then
hlgroups[opt] = colors[val]
elseif valtype == "table" then

-- transform table to color
hlgroups[opt] = #val == 2 and lighten(colors[val[1]], val[2])
or mixcolors(colors[val[1]], colors[val[2]], val[3])
Expand Down Expand Up @@ -149,6 +148,7 @@ M.compile = function()
end

M.str_to_cache("term", require "base46.term")
M.str_to_cache("colors", require "base46.color_vars")

local all_str = ""

Expand Down

1 comment on commit e9d2562

@siduck
Copy link
Member Author

@siduck siduck commented on e9d2562 Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local colors = dofile(vim.g.base46_cache .. "colors")

vim.print(colors) -- to see everything!
print(colors.blue)   

Please sign in to comment.