From 125d83ccf9c9d390ecde624d5718821f91e4b0e3 Mon Sep 17 00:00:00 2001 From: Squibid Date: Fri, 25 Apr 2025 16:20:23 -0500 Subject: [PATCH] add some logging to the lazy utils --- lua/lazy/utils.lua | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lua/lazy/utils.lua b/lua/lazy/utils.lua index 2551926..4f3b5d2 100644 --- a/lua/lazy/utils.lua +++ b/lua/lazy/utils.lua @@ -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()