Skip to content

Commit

Permalink
fix(ft): always trigger FileType when lazy-loading on ft
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 27, 2022
1 parent b1e1b33 commit 5618076
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/lazy/core/handler/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ M.trigger_events = {
BufRead = { "BufReadPre", "BufRead" },
BufReadPost = { "BufReadPre", "BufRead", "BufReadPost" },
}
M.trigger_always = { "FileType" }
M.group = vim.api.nvim_create_augroup("lazy_handler_event", { clear = true })

---@param value string
Expand All @@ -31,8 +32,12 @@ function M:_add(value)
local groups = M.get_augroups(event, pattern)
-- load the plugins
Loader.load(self.active[value], { [self.type] = value })
-- check if any plugin created an event handler for this event and fire the group
M.trigger(event, pattern, groups)
if vim.tbl_contains(M.trigger_always, event) then
vim.cmd("do " .. event)
else
-- check if any plugin created an event handler for this event and fire the group
M.trigger(event, pattern, groups)
end
Util.track()
end,
})
Expand Down

0 comments on commit 5618076

Please sign in to comment.