local M = {} M.setup = function() -- NOTE: Remove trailing whitespace on save vim.api.nvim_create_autocmd('BufWritePre', { command = '%s/\\s\\+$//e', }) -- NOTE: Handles issues with cmdheight=0, waiting for -- NOTE: https://github.com/neovim/neovim/pull/18961 -- NOTE: to be merged vim.api.nvim_create_autocmd('RecordingEnter', { pattern = '*', callback = function() vim.opt_local.cmdheight = 1 vim.notify('Began Recording Macro', '', { title = 'Macro' }) end, }) vim.api.nvim_create_autocmd('RecordingLeave', { pattern = '*', callback = function() local timer = vim.loop.new_timer() -- HACK: Timer is here because we need to close cmdheight AFTER -- HACK: the macro is ended, not during the RecordingLeave event timer:start( 50, 0, vim.schedule_wrap(function() vim.opt_local.cmdheight = 0 vim.notify('Stopped Recording Macro', '', { title = 'Macro' }) end) ) end, }) vim.api.nvim_create_autocmd('CmdlineEnter', { pattern = '*', callback = function() vim.opt_local.cmdheight = 1 end, }) vim.api.nvim_create_autocmd('CmdlineLeave', { pattern = '*', callback = function() local timer = vim.loop.new_timer() -- HACK: Timer is here because we need to close cmdheight AFTER -- HACK: the macro is ended, not during the RecordingLeave event timer:start( 50, 0, vim.schedule_wrap(function() vim.opt_local.cmdheight = 0 vim.notify('Stopped Recording Macro', '', { title = 'Macro' }) end) ) end, }) end return M