From 5618076a451232184b3ed2572ec85573896f48d4 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 27 Dec 2022 08:57:43 +0100 Subject: [PATCH] fix(ft): always trigger FileType when lazy-loading on ft --- lua/lazy/core/handler/event.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/lazy/core/handler/event.lua b/lua/lazy/core/handler/event.lua index 7e38afa..6bdaf10 100644 --- a/lua/lazy/core/handler/event.lua +++ b/lua/lazy/core/handler/event.lua @@ -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 @@ -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, })