add better type definitions, and fix a bug related to...
lua indexing my beloved
This commit is contained in:
@ -3,10 +3,10 @@ local packager = require('dep.package')
|
||||
|
||||
---@class lazy_loader
|
||||
---@field load function the function to load the plugin
|
||||
---@field command_ids table the commands that have been registered
|
||||
---@field auto_ids table the auto commands that have been registered
|
||||
---@field keybind_ids table the keybinds that have been registered
|
||||
---@field plugin_ids table the plugins that have been registered
|
||||
---@field command_ids string[] the commands that have been registered
|
||||
---@field auto_ids number[] the auto commands that have been registered
|
||||
---@field keybind_ids table[] the keybinds that have been registered
|
||||
---@field plugin_ids table[] the plugins that have been registered
|
||||
local lazy_loader = {}
|
||||
|
||||
--- create a new instance of lazy
|
||||
@ -133,29 +133,29 @@ end
|
||||
--- cleanup all the callbacks, and load the plugin
|
||||
function lazy_loader:cleanup()
|
||||
-- cleanup user commands
|
||||
for _, command_id in pairs(self.command_ids) do
|
||||
for _, command_id in ipairs(self.command_ids) do
|
||||
local ok, err = pcall(vim.api.nvim_del_user_command, command_id)
|
||||
if not ok then
|
||||
logger:log("lazy", err or "failed to delete user command")
|
||||
end
|
||||
end
|
||||
-- cleanup auto commands
|
||||
for _, auto_id in pairs(self.auto_ids) do
|
||||
for _, auto_id in ipairs(self.auto_ids) do
|
||||
local ok, err = pcall(vim.api.nvim_del_autocmd, auto_id)
|
||||
if not ok then
|
||||
logger:log("lazy", err or "failed to delete auto command")
|
||||
end
|
||||
end
|
||||
-- cleanup keymaps
|
||||
for _, keybind_id in pairs(self.keybind_ids) do
|
||||
for _, keybind_id in ipairs(self.keybind_ids) do
|
||||
local ok, err = pcall(vim.keymap.del, keybind_id.mode, keybind_id.bind, {})
|
||||
if not ok then
|
||||
logger:log("lazy", err or "failed to delete keymap")
|
||||
end
|
||||
end
|
||||
-- cleanup plugins
|
||||
for _, plugin_id in pairs(self.plugin_ids) do
|
||||
table.remove(packager.get_packages()[plugin_id[0]].on_load, plugin_id[1])
|
||||
for _, plugin_id in ipairs(self.plugin_ids) do
|
||||
table.remove(packager.get_packages()[plugin_id[1]].on_load, plugin_id[2])
|
||||
end
|
||||
-- load the plugin
|
||||
self:load()
|
||||
|
Reference in New Issue
Block a user