mirror of https://github.com/folke/lazy.nvim.git
fix(event): pass data to event lazy loaders. Fixes #922
This commit is contained in:
parent
5af331ea65
commit
fd94e69ceb
|
@ -23,7 +23,7 @@ function M:_add(value)
|
||||||
group = self.group,
|
group = self.group,
|
||||||
once = true,
|
once = true,
|
||||||
pattern = pattern,
|
pattern = pattern,
|
||||||
callback = function()
|
callback = function(ev)
|
||||||
if not self.active[value] then
|
if not self.active[value] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@ function M:_add(value)
|
||||||
-- load the plugins
|
-- load the plugins
|
||||||
Loader.load(self.active[value], { [self.type] = value })
|
Loader.load(self.active[value], { [self.type] = value })
|
||||||
-- check if any plugin created an event handler for this event and fire the group
|
-- check if any plugin created an event handler for this event and fire the group
|
||||||
self:trigger(event, pattern, groups)
|
self:trigger(event, pattern, groups, ev.data)
|
||||||
Util.track()
|
Util.track()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -61,7 +61,7 @@ end
|
||||||
---@param event string|string[]
|
---@param event string|string[]
|
||||||
---@param pattern? string
|
---@param pattern? string
|
||||||
---@param groups table<string,true>
|
---@param groups table<string,true>
|
||||||
function M:trigger(event, pattern, groups)
|
function M:trigger(event, pattern, groups, data)
|
||||||
local events = M.trigger_events[event] or { event }
|
local events = M.trigger_events[event] or { event }
|
||||||
---@cast events string[]
|
---@cast events string[]
|
||||||
for _, e in ipairs(events) do
|
for _, e in ipairs(events) do
|
||||||
|
@ -77,7 +77,7 @@ function M:trigger(event, pattern, groups)
|
||||||
end
|
end
|
||||||
Util.track({ event = autocmd.group_name })
|
Util.track({ event = autocmd.group_name })
|
||||||
Util.try(function()
|
Util.try(function()
|
||||||
vim.api.nvim_exec_autocmds(autocmd.event, { group = autocmd.group, modeline = false })
|
vim.api.nvim_exec_autocmds(autocmd.event, { group = autocmd.group, modeline = false, data = data })
|
||||||
Util.track()
|
Util.track()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue