mirror of
https://github.com/gabehf/base46.git
synced 2026-03-11 00:10:32 -07:00
feat(compiler): reduce bytecode size (#169)
* feat(compiler): reduce bytecode size * added credits to nullchilly properly --------- Co-authored-by: Siduck siduck@tutanota.com>
This commit is contained in:
parent
7b1f22a690
commit
eea1c3155a
1 changed files with 4 additions and 6 deletions
|
|
@ -100,20 +100,18 @@ M.table_to_str = function(tb)
|
|||
end
|
||||
|
||||
M.saveStr_to_cache = function(filename, tb)
|
||||
-- Thanks to https://github.com/EdenEast/nightfox.nvim
|
||||
-- Thanks to https://github.com/nullchilly and https://github.com/EdenEast/nightfox.nvim
|
||||
-- It helped me understand string.dump stuff
|
||||
|
||||
local bg_opt = "vim.opt.bg='" .. M.get_theme_tb "type" .. "'"
|
||||
local defaults_cond = filename == "defaults" and bg_opt or ""
|
||||
|
||||
local cache_path = vim.fn.stdpath "cache" .. "/nvchad/base46/"
|
||||
local lines = 'require("base46").compiled = string.dump(function()' .. defaults_cond .. M.table_to_str(tb) .. "end)"
|
||||
local lines = "return string.dump(function()" .. defaults_cond .. M.table_to_str(tb) .. "end, true)"
|
||||
local file = io.open(cache_path .. filename, "wb")
|
||||
|
||||
loadstring(lines, "=")()
|
||||
|
||||
if file then
|
||||
file:write(require("base46").compiled)
|
||||
file:write(loadstring(lines)())
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
|
|
@ -182,7 +180,7 @@ M.toggle_theme = function()
|
|||
g.toggle_theme_icon = " "
|
||||
require("nvchad").replace_word('theme = "' .. theme2, 'theme = "' .. theme1)
|
||||
end
|
||||
|
||||
|
||||
M.load_all_highlights()
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue