Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add recording events to refresh events #1227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikesmithgh
Copy link

@mikesmithgh mikesmithgh commented Apr 9, 2024

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' },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant