get nvim colorscheme from colors util
This commit is contained in:
parent
db24cbafa5
commit
45485c5cdc
3 changed files with 28 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ if not vim.loop.fs_stat(lazypath) then
|
|||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
local Utils = require("juancwu.utils")
|
||||
require("juancwu.config").setup({
|
||||
colorscheme = "kanagawa-dragon",
|
||||
colorscheme = Utils.colors.get_timebased_colorscheme(),
|
||||
})
|
||||
|
|
|
|||
21
nvim/lua/juancwu/utils/colors.lua
Normal file
21
nvim/lua/juancwu/utils/colors.lua
Normal 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
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
---@class Utils
|
||||
---@field os juancwu.utils.os
|
||||
---@field colors juancwu.utils.colors
|
||||
local M = setmetatable({}, {
|
||||
__index = function(t, k)
|
||||
t[k] = require("juancwu.utils." .. k)
|
||||
return t[k]
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue