@@ -28,11 +28,11 @@ function M:_add(value)
28
28
return
29
29
end
30
30
Util .track ({ [self .type ] = value })
31
- local groups = M .get_augroups (event )
31
+ local groups = M .get_augroups (event , pattern )
32
32
-- load the plugins
33
33
Loader .load (self .active [value ], { [self .type ] = value })
34
34
-- check if any plugin created an event handler for this event and fire the group
35
- self :trigger (event , groups )
35
+ self :trigger (event , pattern , groups )
36
36
Util .track ()
37
37
end ,
38
38
})
45
45
46
46
-- Get all augroups for the events
47
47
--- @param event string
48
- function M .get_augroups (event )
48
+ --- @param pattern ? string
49
+ function M .get_augroups (event , pattern )
49
50
local events = M .trigger_events [event ] or { event }
50
51
--- @type table<string,true>
51
52
local groups = {}
52
- for _ , autocmd in ipairs (vim .api .nvim_get_autocmds ({ event = events })) do
53
+ for _ , autocmd in ipairs (vim .api .nvim_get_autocmds ({ event = events , pattern = pattern })) do
53
54
if autocmd .group then
54
55
groups [autocmd .group ] = true
55
56
end
60
61
--- @param event string | string[]
61
62
--- @param pattern ? string
62
63
--- @param groups table<string,true>
63
- function M :trigger (event , groups )
64
+ function M :trigger (event , pattern , groups )
64
65
local events = M .trigger_events [event ] or { event }
65
66
--- @cast events string[]
66
67
for _ , e in ipairs (events ) do
67
- for _ , autocmd in ipairs (vim .api .nvim_get_autocmds ({ event = e })) do
68
+ for _ , autocmd in ipairs (vim .api .nvim_get_autocmds ({ event = e , pattern = pattern })) do
68
69
if autocmd .event == e and autocmd .group and not groups [autocmd .group ] then
69
70
if Config .options .debug then
70
71
Util .info ({
71
72
" # Firing Events" ,
72
73
" - **group:** `" .. autocmd .group_name .. " `" ,
73
74
" - **event:** " .. autocmd .event ,
75
+ pattern and (" - **pattern:** " .. pattern ),
74
76
})
75
77
end
76
78
Util .track ({ event = autocmd .group_name })
0 commit comments