lualine.nvim
lualine.nvim copied to clipboard
feat: add recording events to refresh events
I'd like to add the events RecordingEnter
and RecordingLeave
to the default refresh events.
This is useful for cases where the recording register (e.g., vim.fn.reg_recording()
) is displayed in lualine. Currently, lualine has to wait until the next refresh which causes a delay. Adding the events RecordingEnter
and RecordingLeave
immediately triggers an update for a better experience.
For example, noice.nvim does this with the following snippet from its README.
{
require('noice').api.status.mode.get,
cond = require('noice').api.status.mode.has,
color = { fg = '#ff9e64' },
}
This could also be accomplished manually via:
local rec_msg = ''
vim.api.nvim_create_autocmd({ 'RecordingEnter', 'RecordingLeave' }, {
group = vim.api.nvim_create_augroup('LualineRecordingSection', { clear = true }),
callback = function(e)
if e.event == 'RecordingLeave' then
rec_msg = ''
else
rec_msg = 'recording @' .. vim.fn.reg_recording()
end
end,
})
and with the lualine section:
{
function()
return rec_msg
end,
color = { fg = '#ff9e64' },
}