mirror of
https://github.com/gabehf/base46.git
synced 2026-03-09 07:28:50 -07:00
add transparency toggler function | https://github.com/NvChad/NvChad/issues/1161
This commit is contained in:
parent
1a4e761b8a
commit
4c05b1de9f
2 changed files with 36 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
local M = {}
|
||||
local g = vim.g
|
||||
local config = require("core.utils").load_config()
|
||||
|
||||
M.get_theme_tb = function(name, type)
|
||||
|
|
@ -18,7 +19,7 @@ M.get_theme_tb = function(name, type)
|
|||
end
|
||||
|
||||
M.get_colors = function(type)
|
||||
local name = vim.g.nvchad_theme
|
||||
local name = g.nvchad_theme
|
||||
return M.get_theme_tb(name, type)
|
||||
end
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ end
|
|||
|
||||
M.load_theme = function()
|
||||
-- set bg option
|
||||
local theme_type = M.get_theme_tb(vim.g.nvchad_theme, "type") -- dark/light
|
||||
local theme_type = M.get_theme_tb(g.nvchad_theme, "type") -- dark/light
|
||||
vim.opt.bg = theme_type
|
||||
|
||||
M.clear_highlights "BufferLine"
|
||||
|
|
@ -72,21 +73,21 @@ M.toggle_theme = function()
|
|||
local theme1 = themes[1]
|
||||
local theme2 = themes[2]
|
||||
|
||||
if vim.g.nvchad_theme == theme1 or vim.g.nvchad_theme == theme2 then
|
||||
if vim.g.toggle_theme_icon == " " then
|
||||
vim.g.toggle_theme_icon = " "
|
||||
if g.nvchad_theme == theme1 or g.nvchad_theme == theme2 then
|
||||
if g.toggle_theme_icon == " " then
|
||||
g.toggle_theme_icon = " "
|
||||
else
|
||||
vim.g.toggle_theme_icon = " "
|
||||
g.toggle_theme_icon = " "
|
||||
end
|
||||
end
|
||||
|
||||
if vim.g.nvchad_theme == theme1 then
|
||||
vim.g.nvchad_theme = theme2
|
||||
if g.nvchad_theme == theme1 then
|
||||
g.nvchad_theme = theme2
|
||||
|
||||
require("nvchad").reload_theme()
|
||||
require("nvchad").change_theme(theme1, theme2)
|
||||
elseif vim.g.nvchad_theme == theme2 then
|
||||
vim.g.nvchad_theme = theme1
|
||||
elseif g.nvchad_theme == theme2 then
|
||||
g.nvchad_theme = theme1
|
||||
|
||||
require("nvchad").reload_theme()
|
||||
require("nvchad").change_theme(theme2, theme1)
|
||||
|
|
@ -95,4 +96,28 @@ M.toggle_theme = function()
|
|||
end
|
||||
end
|
||||
|
||||
M.toggle_transparency = function()
|
||||
local transparency_status = require("core.utils").load_config().ui.transparency
|
||||
local write_data = require("nvchad").write_data
|
||||
|
||||
local function save_chadrc_data()
|
||||
local old_data = "transparency = " .. tostring(transparency_status)
|
||||
local new_data = "transparency = " .. tostring(g.transparency)
|
||||
|
||||
write_data(old_data, new_data)
|
||||
end
|
||||
|
||||
if g.transparency then
|
||||
g.transparency = false
|
||||
|
||||
M.load_theme()
|
||||
save_chadrc_data()
|
||||
else
|
||||
g.transparency = true
|
||||
|
||||
M.load_theme()
|
||||
save_chadrc_data()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ if ui.hl_override then
|
|||
end
|
||||
|
||||
-- local set_transparent = nvchad.load_config().ui.transparency
|
||||
if ui.transparency then
|
||||
if vim.g.transparency then
|
||||
highlights = merge_tb(highlights, require "nv_glassy")
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue