From 0e1bf5aad478a4030f31acd8bbea874b71e42f43 Mon Sep 17 00:00:00 2001 From: Ian Griffin Date: Fri, 30 Sep 2022 20:06:55 +0800 Subject: initial commit --- lua/conftool.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lua/conftool.lua (limited to 'lua/conftool.lua') 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 -- cgit v1.3