From 7fcb36f16dc85c91b82bee83d30754fc970574dc Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 14 Mar 2021 16:55:38 -0400 Subject: lotsa cool updates --- lua/utils.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lua/utils.lua (limited to 'lua/utils.lua') diff --git a/lua/utils.lua b/lua/utils.lua new file mode 100644 index 00000000..59c905f1 --- /dev/null +++ b/lua/utils.lua @@ -0,0 +1,29 @@ +local function define_augroups(definitions) -- {{{1 + -- 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 + +define_augroups( + {_general_settings = { + {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'IncSearch\', timeout = 200})'}, + }, + } +) + -- cgit v1.2.3