From 41c1fe37d9a4f297ce85c36c090425589c2df913 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 24 Aug 2024 16:22:32 -0400 Subject: [PATCH] fix: ensure accurate detection of plugin installation across lazy, packer, and vim-plug --- lua/data/func.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lua/data/func.lua b/lua/data/func.lua index 21f7abb..1517700 100644 --- a/lua/data/func.lua +++ b/lua/data/func.lua @@ -128,7 +128,23 @@ end -- Check if plugin is installed function M.is_installed(plugin) - return require("lazy.core.config").plugins[plugin] ~= nil + -- Check for lazy.nvim + local lazy_installed = pcall(require, "lazy") + if lazy_installed then + return require("lazy.core.config").plugins[plugin] ~= nil + end + -- Check for packer.nvim + local packer_installed = pcall(require, "packer_plugins") + if packer_installed then + ---@diagnostic disable-next-line: undefined-field + return _G.packer_plugins and _G.packer_plugins[plugin] ~= nil + end + -- Check for vim-plug + if vim.fn.exists("g:plugs") == 1 then + return vim.g.plugs[plugin] ~= nil + end + -- Plugin not found + return false end -- Function to convert RGB to hexadecimal