feat(nvim): add datetime to statusline
This commit is contained in:
parent
aeece242aa
commit
3b52c99cf1
@ -1,3 +1,4 @@
|
||||
local util = require("utils.funcs")
|
||||
local present, lualine = pcall(require, "lualine")
|
||||
if not present then
|
||||
return
|
||||
@ -64,6 +65,25 @@ local show_lsp_name = {
|
||||
color = { fg = "#957fb8" },
|
||||
}
|
||||
|
||||
local LuaLineDateTimeHls = function()
|
||||
return {
|
||||
normal = {
|
||||
fg = "#957FB8",
|
||||
bg = util.get_color("lualine_c_normal", "bg#"),
|
||||
},
|
||||
hour_changed = {
|
||||
fg = "#FFA066",
|
||||
bg = util.get_color("lualine_c_normal", "bg#"),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
vim.api.nvim_set_hl(0, "LuaLineDateTime", LuaLineDateTimeHls().normal)
|
||||
|
||||
local datetime_section = function()
|
||||
return os.date("%I:%M %p")
|
||||
end
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
@ -87,6 +107,11 @@ lualine.setup({
|
||||
fmt = show_macro_recording,
|
||||
},
|
||||
show_lsp_name,
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
||||
},
|
||||
},
|
||||
lualine_c = {},
|
||||
lualine_x = {
|
||||
@ -133,11 +158,6 @@ lualine.setup({
|
||||
"diff",
|
||||
symbols = { added = " ", modified = " ", removed = " " },
|
||||
},
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
||||
},
|
||||
{
|
||||
"macro-recording",
|
||||
fmt = show_macro_recording,
|
||||
@ -170,6 +190,14 @@ lualine.setup({
|
||||
require("lazy.status").updates,
|
||||
cond = require("lazy.status").has_updates,
|
||||
},
|
||||
{
|
||||
"datetime",
|
||||
fmt = datetime_section,
|
||||
color = "LuaLineDateTime",
|
||||
separator = {
|
||||
right = '%#lualine_transitional_lualine_b_normal_to_lualine_c_normal#'
|
||||
}
|
||||
},
|
||||
},
|
||||
lualine_y = {
|
||||
{
|
||||
@ -214,5 +242,24 @@ vim.api.nvim_create_autocmd("RecordingLeave", {
|
||||
})
|
||||
end)
|
||||
)
|
||||
timer:close()
|
||||
end,
|
||||
})
|
||||
|
||||
local last_date_hour = tonumber(os.date("%H"))
|
||||
local date_timer = vim.loop.new_timer()
|
||||
date_timer:start(
|
||||
100,
|
||||
1000,
|
||||
vim.schedule_wrap(function()
|
||||
vim.api.nvim_set_hl(0, "LuaLineDateTime", LuaLineDateTimeHls().normal)
|
||||
local curr_date_hour = tonumber(os.date("%H"))
|
||||
if curr_date_hour ~= last_date_hour then
|
||||
vim.api.nvim_set_hl(0, "LuaLineDateTime", LuaLineDateTimeHls().hour_changed)
|
||||
end
|
||||
last_date_hour = curr_date_hour
|
||||
lualine.refresh({
|
||||
place = { "datetime" },
|
||||
})
|
||||
end)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user