2021-05-25 16:06:54 -07:00
|
|
|
local lv_utils = {}
|
2021-03-17 00:17:41 -04:00
|
|
|
|
2021-05-25 16:06:54 -07:00
|
|
|
function lv_utils.define_augroups(definitions) -- {{{1
|
2021-07-04 22:14:01 -03:00
|
|
|
-- Create autocommand groups based on the passed definitions
|
|
|
|
--
|
|
|
|
-- The key will be the name of the group, and each definition
|
|
|
|
-- within the group should have:
|
|
|
|
-- 1. Trigger
|
|
|
|
-- 2. Pattern
|
|
|
|
-- 3. Text
|
|
|
|
-- just like how they would normally be defined from Vim itself
|
|
|
|
for group_name, definition in pairs(definitions) do
|
|
|
|
vim.cmd("augroup " .. group_name)
|
|
|
|
vim.cmd "autocmd!"
|
2021-03-14 16:55:38 -04:00
|
|
|
|
2021-07-04 22:14:01 -03:00
|
|
|
for _, def in pairs(definition) do
|
|
|
|
local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ")
|
|
|
|
vim.cmd(command)
|
2021-03-14 16:55:38 -04:00
|
|
|
end
|
2021-03-22 22:10:58 -04:00
|
|
|
|
2021-07-04 22:14:01 -03:00
|
|
|
vim.cmd "augroup END"
|
|
|
|
end
|
|
|
|
end
|
2021-03-17 00:17:41 -04:00
|
|
|
|
2021-05-25 16:06:54 -07:00
|
|
|
return lv_utils
|