LunarVim/lua/lv-utils/init.lua

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