Skip to content

Commit 52b8580

Browse files
committed
remove all autocmds
1 parent 0a14f30 commit 52b8580

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lua/strive/init.lua

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,10 @@ function Plugin:load(opts)
679679
self:call_setup()
680680

681681
self.status = STATUS.LOADED
682-
if self.group_id then
683-
api.nvim_del_augroup_by_id(self.group_id)
682+
if self.group_ids then
683+
for _, id in ipairs(self.group_ids) do
684+
api.nvim_del_augroup_by_id(id)
685+
end
684686
end
685687

686688
local deps_count = #self.dependencies
@@ -729,7 +731,9 @@ end
729731
function Plugin:on(events)
730732
self.is_lazy = true
731733
self.events = type(events) ~= 'table' and { events } or events
732-
self.group_id = api.nvim_create_augroup('strive_' .. self.plugin_name, { clear = true })
734+
self.group_ids = self.group_id or {}
735+
local id = api.nvim_create_augroup('strive_' .. self.plugin_name, { clear = true })
736+
table.insert(self.group_ids, id)
733737

734738
-- Create autocmds for each event within this group
735739
for _, event in ipairs(self.events) do
@@ -740,7 +744,7 @@ function Plugin:on(events)
740744
end
741745

742746
api.nvim_create_autocmd(event, {
743-
group = self.group_id,
747+
group = id,
744748
pattern = pattern,
745749
once = true,
746750
callback = function(args)
@@ -765,11 +769,14 @@ end
765769
function Plugin:ft(filetypes)
766770
self.is_lazy = true
767771
self.filetypes = type(filetypes) ~= 'table' and { filetypes } or filetypes
772+
self.group_ids = self.group_ids or {}
773+
local id = api.nvim_create_augroup('strive_' .. self.plugin_name, { clear = true })
774+
self.group_ids[#self.group_ids + 1] = id
768775
api.nvim_create_autocmd('FileType', {
769-
group = api.nvim_create_augroup('strive_' .. self.plugin_name, { clear = true }),
776+
group = id,
770777
pattern = self.filetypes,
771778
once = true,
772-
callback = function()
779+
callback = function(args)
773780
if not self.loaded then
774781
self:load()
775782
end

0 commit comments

Comments
 (0)