LunarVim/lua/lv-utils/init.lua

26 lines
679 B
Lua
Raw Normal View History

local lv_utils = {}
2021-03-17 05:17:41 +01:00
function lv_utils.define_augroups(definitions) -- {{{1
2021-07-05 03:14:01 +02: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 21:55:38 +01:00
2021-07-05 03:14:01 +02:00
for _, def in pairs(definition) do
local command = table.concat(vim.tbl_flatten { "autocmd", def }, " ")
vim.cmd(command)
2021-03-14 21:55:38 +01:00
end
2021-03-23 03:10:58 +01:00
2021-07-05 03:14:01 +02:00
vim.cmd "augroup END"
end
end
2021-03-17 05:17:41 +01:00
return lv_utils