Skip to content

Commit

Permalink
🚀 feat(core): Add colorscheme.lua file for theme management
Browse files Browse the repository at this point in the history
  • Loading branch information
Syuq committed Mar 7, 2024
1 parent e721137 commit 8fc75ec
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions lua/core/colorscheme.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
local function daylight()
local h = tonumber(os.date('%H'))
if h > 8 and h < 17 then
return 'light'
else
return 'dark'
end
end

local loading_theme

local function randomscheme()
math.randomseed(os.time())
local themes = {
'starry.nvim',
'aurora',
'starry.nvim',
'aurora',
'catppuccin',
'galaxy',
}
local style = daylight()

if style == 'light' then
-- vim.o.background = "light"
themes = { 'starry.nvim', 'catppuccin' }
end

-- themes = { "starry.nvim", "starry.nvim", "aurora", "galaxy", "catppuccin", "tokyonight.nvim" }
themes = { 'starry.nvim', 'aurora', 'galaxy' }
-- themes = { 'galaxy' }
local v = math.random(1, #themes)

loading_theme = themes[v]
return loading_theme
end

local function load_colorscheme(theme)
if not theme then
theme = randomscheme()
end
lprint('loading theme: ' .. theme)
if theme == 'galaxy' then
require('modules.ui.galaxy').shine()
else
require('lazy').load({ plugins = { theme } })
end
end

return {
randomscheme = randomscheme,
load_colorscheme = load_colorscheme,
current_theme = loading_theme,
}

0 comments on commit 8fc75ec

Please sign in to comment.