get nvim colorscheme from colors util

This commit is contained in:
jc 2024-06-06 14:10:51 -04:00
commit 45485c5cdc
No known key found for this signature in database
3 changed files with 28 additions and 5 deletions

View file

@ -11,6 +11,7 @@ if not vim.loop.fs_stat(lazypath) then
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
local Utils = require("juancwu.utils")
require("juancwu.config").setup({ require("juancwu.config").setup({
colorscheme = "kanagawa-dragon", colorscheme = Utils.colors.get_timebased_colorscheme(),
}) })

View file

@ -0,0 +1,21 @@
---@class juancwu.utils.colors
local M = {}
---@return boolean
function M.is_daytime()
local current_hour = tonumber(os.date("%H"))
return current_hour >= 7 and current_hour < 19
end
---@return string
function M.get_timebased_colorscheme()
local light = "kanagawa-lotus"
local dark = "kanagawa-dragon"
if M.is_daytime() then
return light
else
return dark
end
end
return M

View file

@ -1,10 +1,11 @@
---@class Utils ---@class Utils
---@field os juancwu.utils.os ---@field os juancwu.utils.os
---@field colors juancwu.utils.colors
local M = setmetatable({}, { local M = setmetatable({}, {
__index = function(t, k) __index = function(t, k)
t[k] = require("juancwu.utils." .. k) t[k] = require("juancwu.utils." .. k)
return t[k] return t[k]
end end,
}) })
return M return M