Files
nvim-kickstart/lua/custom/colortheme.lua
T
2026-08-28 10:02:40 +02:00

41 lines
1.5 KiB
Lua

-- Detect dark or light theme saved in .colorscheme. defaults to dark
local background_mode
local f = io.open(os.getenv('HOME') .. '/.colorscheme', 'r')
if f ~= nil then
background_mode = f:read('*all')
background_mode = string.gsub(background_mode, "\n", '')
f:close()
else
background_mode = 'dark'
end
-- Applying these via the ColorScheme autocmd (rather than one-off `:highlight`
-- calls after the colorscheme is set) means every plugin that listens for
-- ColorScheme to pick up transparency - not just whatever runs immediately
-- after this file - sees the final, transparent highlights too.
vim.api.nvim_create_autocmd("ColorScheme", {
callback = function()
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "NONE", fg = "#cdd6f5" })
vim.api.nvim_set_hl(0, "FloatBorder", { bg = "NONE", fg = "#3e4452" })
if background_mode ~= 'dark' then
vim.api.nvim_set_hl(0, "Normal", { bg = "NONE" })
vim.api.nvim_set_hl(0, "StatusLine", { bg = "NONE" })
vim.api.nvim_set_hl(0, "LineNr", { bg = "NONE" })
vim.api.nvim_set_hl(0, "CursorLineNr", { bg = "NONE" })
vim.api.nvim_set_hl(0, "TabLine", { bg = "NONE" })
vim.api.nvim_set_hl(0, "Visual", { bg = "NONE" })
vim.api.nvim_set_hl(0, "NormalNC", { bg = "NONE" })
end
end
})
-- use ayu theme for dark mode, selenized for light mode
if background_mode == 'dark' then
vim.g.ayucolor = background_mode
vim.cmd("set background=" .. background_mode)
vim.cmd("colorscheme catppuccin-mocha")
else
vim.cmd("colorscheme zenbones")
vim.cmd("set background=" .. background_mode)
end