1 | 1 | | return { |
2 | 2 | | "rebelot/heirline.nvim", |
| 3 | + | dependencies = { |
| 4 | + | "AstroNvim/astroui", |
| 5 | + | ---@type AstroUIOpts |
| 6 | + | opts = { |
| 7 | + | icons = { |
| 8 | + | Clock = "", -- add icon for clock |
| 9 | + | }, |
| 10 | + | status = { |
| 11 | + | separators = { |
| 12 | + | left = { "", " " }, |
| 13 | + | right = { " ", "" }, |
| 14 | + | }, |
| 15 | + | }, |
| 16 | + | }, |
| 17 | + | }, |
3 | 18 | | opts = function(_, opts) |
4 | 19 | | local status = require "astroui.status" |
| 20 | + | -- custom statusline |
5 | 21 | | opts.statusline[3] = status.component.file_info { filetype = {}, filename = false } |
6 | 22 | | |
| 23 | + | -- add time to mode indicator |
| 24 | + | opts.statusline[#opts.statusline] = status.component.builder { |
| 25 | + | { |
| 26 | + | provider = function() |
| 27 | + | local time = os.date "%H:%M" -- show hour and minute in 24 hour format |
| 28 | + | ---@cast time string |
| 29 | + | return status.utils.stylize(time, { |
| 30 | + | icon = { kind = "Clock", padding = { right = 1 } }, -- add icon |
| 31 | + | padding = { right = 1 }, -- pad the right side |
| 32 | + | }) |
| 33 | + | end, |
| 34 | + | }, |
| 35 | + | update = { |
| 36 | + | "User", |
| 37 | + | "ModeChanged", |
| 38 | + | callback = vim.schedule_wrap(function(_, args) |
| 39 | + | if -- update on user UpdateTime event and mode change |
| 40 | + | (args.event == "User" and args.match == "UpdateTime") |
| 41 | + | or (args.event == "ModeChanged" and args.match:match ".*:.*") |
| 42 | + | then |
| 43 | + | vim.cmd.redrawstatus() |
| 44 | + | end |
| 45 | + | end), -- redraw on update |
| 46 | + | }, |
| 47 | + | hl = status.hl.get_attributes "mode", -- highlight based on mode attributes |
| 48 | + | surround = { separator = "right", color = status.hl.mode_bg }, -- background highlight based on mode |
| 49 | + | } |
| 50 | + | |
| 51 | + | vim.uv.new_timer():start( -- timer for updating the time |
| 52 | + | (60 - tonumber(os.date "%S")) * 1000, -- offset timer based on current seconds past the minute |
| 53 | + | 60000, -- update every 60 seconds |
| 54 | + | vim.schedule_wrap(function() vim.api.nvim_exec_autocmds("User", { pattern = "UpdateTime", modeline = false }) end) |
| 55 | + | ) |
| 56 | + | |
| 57 | + | -- custom winbar |
7 | 58 | | local path_func = status.provider.filename { modify = ":.:h", fallback = "" } |
8 | 59 | | opts.winbar[1][1] = status.component.separated_path { path_func = path_func } |
9 | 60 | | opts.winbar[2] = { |
| skipped 19 lines |