57 lines
1.8 KiB
Lua
57 lines
1.8 KiB
Lua
-- Autocmds are automatically loaded on the VeryLazy event
|
|
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
|
-- Add any additional autocmds here
|
|
|
|
local autocmds = {
|
|
{ -- Automatically change line numeration
|
|
{ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" },
|
|
{
|
|
group = "auto_number",
|
|
command = 'if &nu && mode() != "i" | set rnu | endif',
|
|
-- callback = function()
|
|
-- if vim.opt.number and vim.fn.mode() ~= "i" then
|
|
-- vim.opt.relativenumber = true
|
|
-- end
|
|
-- end,
|
|
},
|
|
},
|
|
{ -- Automatically change line numeration
|
|
{ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" },
|
|
{
|
|
group = "auto_number",
|
|
command = "if &nu | set nornu | endif",
|
|
-- callback = function()
|
|
-- if vim.opt.number then
|
|
-- vim.opt.relativenumber = false
|
|
-- end
|
|
-- end,
|
|
},
|
|
},
|
|
{ -- Trigger shortcuts script
|
|
"BufWritePost",
|
|
{
|
|
pattern = { "directories", "files" },
|
|
command = "silent!!shortcuts",
|
|
},
|
|
},
|
|
{ -- Trigger xrdb
|
|
"BufWritePost",
|
|
{
|
|
pattern = { "xresources" },
|
|
command = "silent!!xrdb %",
|
|
},
|
|
},
|
|
}
|
|
|
|
vim.api.nvim_create_augroup("user_config", { clear = true })
|
|
for _, entry in ipairs(autocmds) do
|
|
local event = entry[1]
|
|
local opts = entry[2]
|
|
if type(opts.group) == "string" and opts.group ~= "" then
|
|
local exists, _ = pcall(vim.api.nvim_get_autocmds, { group = opts.group })
|
|
if not exists then
|
|
vim.api.nvim_create_augroup(opts.group, {})
|
|
end
|
|
end
|
|
vim.api.nvim_create_autocmd(event, opts)
|
|
end
|