From add8e21a0cd67005643aa61aaead3a8e34164736 Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 29 Jan 2023 18:18:34 +0530 Subject: [PATCH] merge statusline highlights & opt_bg into defaults file --- lua/base46/init.lua | 24 ++++++++---------------- lua/base46/integrations/defaults.lua | 10 +++++++++- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lua/base46/init.lua b/lua/base46/init.lua index 5e39fac..3b0be61 100644 --- a/lua/base46/init.lua +++ b/lua/base46/init.lua @@ -104,8 +104,11 @@ M.saveStr_to_cache = function(filename, tb) -- Thanks to 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()' .. M.table_to_str(tb) .. "end)" + local lines = 'require("base46").compiled = string.dump(function()' .. defaults_cond .. M.table_to_str(tb) .. "end)" local file = io.open(cache_path .. filename, "wb") loadstring(lines, "=")() @@ -121,22 +124,11 @@ M.compile = function() local hl_files = vim.g.base46_custom_path or vim.fn.stdpath "data" .. "/lazy/base46/lua/base46/integrations" for _, file in ipairs(vim.fn.readdir(hl_files)) do - local filename = vim.fn.fnamemodify(file, ":r") - local integration = M.load_highlight(filename) - - -- merge new hl groups added by users - if filename == "defaults" then - integration = M.merge_tb(integration, (M.turn_str_to_color(config.ui.hl_add))) + -- skip caching statusline file as its done in defaults file + if file ~= "statusline" then + local filename = vim.fn.fnamemodify(file, ":r") + M.saveStr_to_cache(filename, M.load_highlight(filename)) end - - M.saveStr_to_cache(filename, integration) - end - - local bg_file = io.open(vim.fn.stdpath "cache" .. "/nvchad/base46/bg", "wb") - - if bg_file then - bg_file:write("vim.opt.bg='" .. M.get_theme_tb "type".."'") - bg_file:close() end end diff --git a/lua/base46/integrations/defaults.lua b/lua/base46/integrations/defaults.lua index ad61c19..61ace71 100644 --- a/lua/base46/integrations/defaults.lua +++ b/lua/base46/integrations/defaults.lua @@ -3,7 +3,7 @@ local theme = require("base46").get_theme_tb "base_16" local generate_color = require("base46.colors").change_hex_lightness -return { +local defaults = { MatchWord = { bg = colors.grey, fg = colors.white, @@ -250,3 +250,11 @@ return { LazyReasonImport = { fg = colors.white }, LazyProgressDone = { fg = colors.green }, } + +-- merge statusilne & hl_add tables! +local merge_tb = require("base46").merge_tb + +defaults = merge_tb(defaults, require("base46").load_highlight "statusline") +defaults = merge_tb(defaults, require("core.utils").load_config().ui.hl_add) + +return defaults