2023-03-12 01:04:48 +01:00
|
|
|
vim.api.nvim_create_autocmd("VimResized", {
|
|
|
|
pattern = "*",
|
|
|
|
command = "wincmd =",
|
|
|
|
desc = "Automatically resize windows when the host window size changes.",
|
|
|
|
})
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
|
|
|
pattern = "*",
|
|
|
|
callback = function()
|
|
|
|
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
|
|
|
|
end,
|
|
|
|
desc = "Highlight yanked text",
|
|
|
|
})
|
|
|
|
|
2023-06-17 22:09:36 +02:00
|
|
|
vim.api.nvim_create_autocmd({ "RecordingEnter", "RecordingLeave" }, {
|
|
|
|
callback = function(data)
|
|
|
|
local msg = data.event == "RecordingEnter" and "Recording macro..."
|
|
|
|
or "Macro recorded"
|
|
|
|
vim.notify(msg, vim.log.levels.INFO, { title = "Macro" })
|
|
|
|
end,
|
|
|
|
desc = "Notify when recording macro",
|
|
|
|
})
|
2023-06-16 20:43:52 +02:00
|
|
|
|
2023-06-17 22:09:36 +02:00
|
|
|
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", {})
|
|
|
|
local ignore_ft = {
|
|
|
|
"",
|
|
|
|
"alpha",
|
|
|
|
"fugitive",
|
|
|
|
"help",
|
|
|
|
"lazy",
|
|
|
|
"NeogitCommitView",
|
|
|
|
"NeogitConsole",
|
|
|
|
"NeogitStatus",
|
|
|
|
"NvimTree",
|
|
|
|
"TelescopePrompt",
|
|
|
|
"toggleterm",
|
|
|
|
"Trouble",
|
|
|
|
}
|
2023-06-16 20:43:52 +02:00
|
|
|
---@param callback fun(): nil
|
|
|
|
local ft_guard = function(callback)
|
|
|
|
if not vim.tbl_contains(ignore_ft, vim.bo.filetype) then
|
|
|
|
callback()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd(
|
|
|
|
{ "InsertEnter", "BufLeave", "WinLeave", "FocusLost" },
|
|
|
|
{
|
|
|
|
callback = function()
|
|
|
|
ft_guard(function()
|
|
|
|
vim.opt_local.rnu = false
|
|
|
|
end)
|
|
|
|
end,
|
|
|
|
group = numbertoggle,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
vim.api.nvim_create_autocmd(
|
|
|
|
{ "InsertLeave", "BufEnter", "WinEnter", "FocusGained" },
|
|
|
|
{
|
|
|
|
callback = function()
|
|
|
|
ft_guard(function()
|
|
|
|
vim.opt_local.rnu = true
|
|
|
|
end)
|
|
|
|
end,
|
|
|
|
group = numbertoggle,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
vim.api.nvim_create_autocmd({ "CmdlineEnter", "CmdlineLeave" }, {
|
|
|
|
callback = function(data)
|
|
|
|
ft_guard(function()
|
|
|
|
vim.opt.rnu = data.event == "CmdlineLeave"
|
|
|
|
vim.cmd("redraw")
|
|
|
|
end)
|
2023-03-12 01:04:48 +01:00
|
|
|
end,
|
2023-06-16 20:43:52 +02:00
|
|
|
group = numbertoggle,
|
2023-03-12 01:04:48 +01:00
|
|
|
})
|