local M = {} M.setup = function() -- NOTE: Highlight text yanked vim.api.nvim_create_autocmd('TextYankPost', { callback = function() vim.highlight.on_yank() end, }) -- 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(arg) 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() local cmdheight_status = vim.api.nvim_get_option_value('cmdheight', {}) if cmdheight_status > 0 then vim.opt_local.cmdheight = 0 vim.notify('Stopped Recording Macro', '', { title = 'Macro' }) end 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() local cmdheight_status = vim.api.nvim_get_option_value('cmdheight', {}) if cmdheight_status > 0 then vim.opt_local.cmdheight = 0 end end) ) end, }) end return M