clean some functions

v2.5
siduck 3 years ago
parent b2564541b7
commit 8a8966df8c

@ -15,7 +15,7 @@ M.get_theme_tb = function(type)
elseif present2 then elseif present2 then
return user_theme[type] return user_theme[type]
else else
error "No such theme bruh >_< " error "No such theme!"
end end
end end
@ -23,19 +23,18 @@ M.merge_tb = function(table1, table2)
return vim.tbl_deep_extend("force", table1, table2) return vim.tbl_deep_extend("force", table1, table2)
end end
-- turns color var names in hl_override/hl_add to actual colors
-- hl_add = { abc = { bg = "one_bg" }} -> bg = colors.one_bg
M.turn_str_to_color = function(tb) M.turn_str_to_color = function(tb)
local colors = M.get_theme_tb "base_30" local colors = M.get_theme_tb "base_30"
for _, hlgroups in pairs(tb) do for _, hlgroups in pairs(tb) do
for opt, val in pairs(hlgroups) do for opt, val in pairs(hlgroups) do
if opt == "fg" or opt == "bg" then if (opt == "fg" or opt == "bg") and not (val:sub(1, 1) == "#" or val == "none" or val == "NONE") then
if val:sub(1, 1) == "#" or val == "none" or val == "NONE" then
else
hlgroups[opt] = colors[val] hlgroups[opt] = colors[val]
end end
end end
end end
end
return tb return tb
end end
@ -194,25 +193,14 @@ M.toggle_theme = function()
end end
M.toggle_transparency = function() M.toggle_transparency = function()
local transparency_status = config.ui.transparency g.transparency = not g.transparency
local write_data = require("nvchad").write_data M.load_all_highlights()
local function save_chadrc_data() -- write transparency value to chadrc
local old_data = "transparency = " .. tostring(transparency_status) local old_data = "transparency = " .. tostring(config.ui.transparency)
local new_data = "transparency = " .. tostring(g.transparency) local new_data = "transparency = " .. tostring(g.transparency)
write_data(old_data, new_data) require("nvchad").replace_word(old_data, new_data)
end
if g.transparency then
g.transparency = false
M.load_all_highlights()
save_chadrc_data()
else
g.transparency = true
M.load_all_highlights()
save_chadrc_data()
end
end end
return M return M

Loading…
Cancel
Save