add some logging to the lazy utils
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
local logger = require('dep.log')
|
||||
|
||||
---@class lazy
|
||||
---@field load function
|
||||
---@field command_ids table
|
||||
---@field auto_ids table
|
||||
---@field keybind_ids table
|
||||
---@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
|
||||
local lazy = {}
|
||||
|
||||
--- create a new instance of lazy
|
||||
@ -88,15 +90,24 @@ end
|
||||
function lazy:cleanup()
|
||||
-- cleanup user commands
|
||||
for _, command_id in pairs(self.command_ids) do
|
||||
vim.api.nvim_del_user_command(command_id)
|
||||
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
|
||||
vim.api.nvim_del_autocmd(auto_id)
|
||||
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
|
||||
vim.keymap.del(keybind_id.mode, keybind_id.bind, {})
|
||||
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
|
||||
-- load the plugin
|
||||
self:load()
|
||||
|
Reference in New Issue
Block a user