polish themes | #67 #78

This commit is contained in:
siduck 2022-06-01 00:51:53 +05:30
parent 7b6fb92bcf
commit 1e803fd654
35 changed files with 552 additions and 436 deletions

View file

@ -1,5 +1,4 @@
local M = {}
local config = require("core.utils").load_config()
M.get_theme_tb = function(name, type)
@ -27,27 +26,32 @@ M.merge_tb = function(table1, table2)
return vim.tbl_deep_extend("force", table1, table2)
end
M.load_theme = function()
-- set bg option
local theme_type = M.get_theme_tb(vim.g.nvchad_theme, "type") -- dark/light
vim.opt.bg = theme_type
-- clear highlights of bufferline (cuz of dynamic devicons hl group on the buffer)
local highlights_raw = vim.split(vim.api.nvim_exec("filter BufferLine hi", true), "\n")
-- credits to https://github.com/max397574 for this function
M.clear_highlights = function(hl_group)
local highlights_raw = vim.split(vim.api.nvim_exec("filter " .. hl_group .. " hi", true), "\n")
local highlight_groups = {}
for _, raw_hi in ipairs(highlights_raw) do
table.insert(highlight_groups, string.match(raw_hi, "BufferLine%a+"))
table.insert(highlight_groups, string.match(raw_hi, hl_group .. "%a+"))
end
for _, highlight in ipairs(highlight_groups) do
vim.cmd([[hi clear ]] .. highlight)
end
-- above highlights clear code by https://github.com/max397574
end
M.load_theme = function()
-- set bg option
local theme_type = M.get_theme_tb(vim.g.nvchad_theme, "type") -- dark/light
vim.opt.bg = theme_type
M.clear_highlights "BufferLine"
M.clear_highlights "TS"
-- reload highlights for theme switcher
require("plenary.reload").reload_module "integrations"
require("plenary.reload").reload_module "chadlights"
require("plenary.reload").reload_module "custom"
require "chadlights"
end