MunifTanjim / nougat.nvim

🍫 Hyperextensible Statusline / Tabline / Winbar for Neovim 🚀
MIT License
192 stars 3 forks source link

:hammer_and_wrench: Show clock #52

Closed uhooi closed 9 months ago

uhooi commented 9 months ago

Did you check the docs and existing issues?

Problem

I want to display a clock, but it is not updating.

nougat.nvim config

-- datetime {{{
local datetime = (function()
  local item = Item {
    sep_left = sep.left_half_circle_solid(true),
    content = {
      Item {
        hl = { bg = color.green, fg = color.bg },
        content = vim.fn.strftime('%H:%M'), -- FIXME: Not refreshing
      },
    },
    sep_right = sep.right_half_circle_solid(true),
  }

  return item
end)()
-- }}}

-- statusline {{{
local stl = Bar('statusline')
stl:add_item(datetime)
bar_util.set_statusline(stl)
-- }}}

Solution

Clock is refreshed.

Alternatives

No response

Additional Context

No response

MunifTanjim commented 9 months ago

You're assigning a string as content. You need to make it a function.

content = function()
  return vim.fn.strftime('%H:%M')
end,
uhooi commented 9 months ago

Oh.. the clock has been refreshed, thank you! https://github.com/uhooi/dotfiles/commit/14fd18b4be38eb04e6532fa0cc521ffbe22ea15d