summaryrefslogtreecommitdiffstatshomepage
path: root/nvim_WIP/lua/config/utils.lua
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-03-04 18:18:22 -0600
committerToby Vincent <tobyv13@gmail.com>2022-03-04 18:18:22 -0600
commit0d3b11c231b5d8536fdc8fbddf167956ec999cc6 (patch)
tree62ddbcfe49228773a5b7425db81a12947dc09450 /nvim_WIP/lua/config/utils.lua
parent6a36592700b75e3658584db672f09ee33b2ba840 (diff)
feat: more tmux/neovim/alacritty
Diffstat (limited to 'nvim_WIP/lua/config/utils.lua')
-rw-r--r--nvim_WIP/lua/config/utils.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/nvim_WIP/lua/config/utils.lua b/nvim_WIP/lua/config/utils.lua
new file mode 100644
index 0000000..9cc02c8
--- /dev/null
+++ b/nvim_WIP/lua/config/utils.lua
@@ -0,0 +1,26 @@
+local cmd = vim.cmd
+local o_s = vim.o
+local map_key = vim.api.nvim_set_keymap
+
+local function opt(o, v, scopes)
+ scopes = scopes or {o_s}
+ for _, s in ipairs(scopes) do s[o] = v end
+end
+
+local function autocmd(group, cmds, clear)
+ clear = clear == nil and false or clear
+ if type(cmds) == 'string' then cmds = {cmds} end
+ cmd('augroup ' .. group)
+ if clear then cmd [[au!]] end
+ for _, c in ipairs(cmds) do cmd('autocmd ' .. c) end
+ cmd [[augroup END]]
+end
+
+local function map(modes, lhs, rhs, opts)
+ opts = opts or {}
+ opts.noremap = opts.noremap == nil and true or opts.noremap
+ if type(modes) == 'string' then modes = {modes} end
+ for _, mode in ipairs(modes) do map_key(mode, lhs, rhs, opts) end
+end
+
+return {opt = opt, autocmd = autocmd, map = map} \ No newline at end of file