Dot_Files/.config/nvim/lua/core/autocmds.lua

63 lines
1.9 KiB
Lua
Raw Normal View History

2022-05-11 21:22:25 -05:00
local M = {}
2022-06-02 20:29:48 -05:00
M.setup = function()
2022-05-11 21:22:25 -05:00
-- NOTE: Remove trailing whitespace on save
vim.api.nvim_create_autocmd('BufWritePre', {
command = '%s/\\s\\+$//e',
})
-- NOTE: Handles issues with cmdheight=0, waiting for
2022-06-18 23:30:30 -05:00
-- 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,
})
2022-06-19 02:33:21 -05:00
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,
})
2022-05-11 21:22:25 -05:00
end
return M