Skip to content

Commit

Permalink
perf(heirline-clock-statusline): optimize clock cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Dec 19, 2023
1 parent e64841d commit 70c2995
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lua/astrocommunity/recipes/heirline-clock-statusline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ return {
---@type AstroUIOpts
opts = {
icons = {
Clock = "", -- add icon for clock
Clock = "", -- add icon for clock
},
},
},
Expand All @@ -24,20 +24,12 @@ return {
})
end,
},
update = {
"User",
"ModeChanged",
callback = vim.schedule_wrap(function(_, args)
if -- update on user UpdateTime event and mode change
(args.event == "User" and args.match == "UpdateTime")
or (args.event == "ModeChanged" and args.match:match ".*:.*")
then
vim.cmd.redrawstatus()
end
end), -- redraw on update
},
update = { "ModeChanged", pattern = "*:*", callback = vim.schedule_wrap(function() vim.cmd.redrawstatus() end) },
hl = status.hl.get_attributes "mode", -- highlight based on mode attributes
surround = { separator = "right", color = status.hl.mode_bg }, -- background highlight based on mode
init = status.init.update_events {
{ "User", pattern = "UpdateTime", callback = vim.schedule_wrap(function() vim.cmd.redrawstatus() end) },
},
}

local uv = vim.uv or vim.loop
Expand Down

0 comments on commit 70c2995

Please sign in to comment.