diff options
author | Yigit Sever | 2023-08-18 23:42:39 +0300 |
---|---|---|
committer | Yigit Sever | 2023-08-18 23:42:39 +0300 |
commit | 387e08c52d9752bc839c71119f140ba8435c3d70 (patch) | |
tree | 3bb20c0e58ccf1e65ced4cfdfb6459e226a24672 /.config/nvim/lua/au.lua | |
parent | 14c14cfcc9aeb4bada6d2429162ded2917f26a94 (diff) | |
download | dotfiles-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.lua | 50 |
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 | -- | ||
4 | local cmd = vim.api.nvim_command | ||
5 | |||
6 | local 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) | ||
15 | end | ||
16 | |||
17 | local S = { | ||
18 | __au = {}, | ||
19 | } | ||
20 | |||
21 | local X = setmetatable({}, { | ||
22 | __index = S, | ||
23 | __newindex = autocmd, | ||
24 | __call = autocmd, | ||
25 | }) | ||
26 | |||
27 | function S.exec(id) | ||
28 | S.__au[id]() | ||
29 | end | ||
30 | |||
31 | function 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) | ||
35 | end | ||
36 | |||
37 | function 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') | ||
48 | end | ||
49 | |||
50 | return X | ||