summaryrefslogtreecommitdiff
path: root/lua/conftool.lua
diff options
context:
space:
mode:
authorIan Griffin <migriffin@disroot.org>2022-09-30 20:06:55 +0800
committerIan Griffin <migriffin@disroot.org>2022-09-30 20:06:55 +0800
commit0e1bf5aad478a4030f31acd8bbea874b71e42f43 (patch)
treeb31312df0273548387a613ff2f4e00bc6828b379 /lua/conftool.lua
initial commit
Diffstat (limited to 'lua/conftool.lua')
-rw-r--r--lua/conftool.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/lua/conftool.lua b/lua/conftool.lua
new file mode 100644
index 0000000..864a925
--- /dev/null
+++ b/lua/conftool.lua
@@ -0,0 +1,37 @@
+local conftool = {}
+
+function conftool.set(...)
+ for _,a in ipairs{...} do
+ if type(a) == "string" then
+ vim.opt[a] = true;
+ elseif type(a) == "table" then
+ local val = false
+ if #a == 2 then val = a[2]
+ elseif #a == 1 then val = true end
+ vim.opt[ a[1] ] = val
+ end
+ end
+end
+
+function conftool.augroup(name, ...)
+ vim.cmd('augroup ' .. name)
+ vim.cmd('autocmd!')
+ for _, autocmd in ipairs{...} do
+ vim.cmd('autocmd ' .. table.concat(autocmd, ' '))
+ end
+ vim.cmd('augroup END')
+end
+
+function conftool.map(mode, keyseq, argcmd, argopts)
+ local opts = {noremap = true}
+ if argopts then opts = vim.tbl_extend('force', defopts, opts) end
+ vim.api.nvim_set_keymap(mode, keyseq, argcmd, opts)
+end
+
+function conftool.defcmd(cmd, repl, attr, redef)
+ if not redef then redef = '' end
+ if not attr then attr = '' end
+ vim.cmd('command' .. redef .. ' ' .. cmd .. ' ' .. attr .. ' ' .. repl)
+end
+
+return conftool