summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/au.lua
diff options
context:
space:
mode:
authorYigit Sever2023-08-18 23:42:39 +0300
committerYigit Sever2023-08-18 23:42:39 +0300
commit387e08c52d9752bc839c71119f140ba8435c3d70 (patch)
tree3bb20c0e58ccf1e65ced4cfdfb6459e226a24672 /.config/nvim/lua/au.lua
parent14c14cfcc9aeb4bada6d2429162ded2917f26a94 (diff)
downloaddotfiles-387e08c52d9752bc839c71119f140ba8435c3d70.tar.gz
dotfiles-387e08c52d9752bc839c71119f140ba8435c3d70.tar.bz2
dotfiles-387e08c52d9752bc839c71119f140ba8435c3d70.zip
nvim: switch to lazy.nvim
revert this as whole, if you miss the good old days
Diffstat (limited to '.config/nvim/lua/au.lua')
-rw-r--r--.config/nvim/lua/au.lua50
1 files changed, 0 insertions, 50 deletions
diff --git a/.config/nvim/lua/au.lua b/.config/nvim/lua/au.lua
deleted file mode 100644
index 305169c..0000000
--- a/.config/nvim/lua/au.lua
+++ /dev/null
@@ -1,50 +0,0 @@
1--
2-- https://gist.github.com/numToStr/1ab83dd2e919de9235f9f774ef8076da
3--
4local cmd = vim.api.nvim_command
5
6local function autocmd(this, event, spec)
7 local is_table = type(spec) == 'table'
8 local pattern = is_table and spec[1] or '*'
9 local action = is_table and spec[2] or spec
10 if type(action) == 'function' then
11 action = this.set(action)
12 end
13 local e = type(event) == 'table' and table.concat(event, ',') or event
14 cmd('autocmd ' .. e .. ' ' .. pattern .. ' ' .. action)
15end
16
17local S = {
18 __au = {},
19}
20
21local X = setmetatable({}, {
22 __index = S,
23 __newindex = autocmd,
24 __call = autocmd,
25})
26
27function S.exec(id)
28 S.__au[id]()
29end
30
31function S.set(fn)
32 local id = string.format('%p', fn)
33 S.__au[id] = fn
34 return string.format('lua require("au").exec("%s")', id)
35end
36
37function S.group(grp, cmds)
38 cmd('augroup ' .. grp)
39 cmd('autocmd!')
40 if type(cmds) == 'function' then
41 cmds(X)
42 else
43 for _, au in ipairs(cmds) do
44 autocmd(S, au[1], { au[2], au[3] })
45 end
46 end
47 cmd('augroup END')
48end
49
50return X