From 299ffdfd538938e3241998de65d0a175fcf73f48 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Jan 2023 10:43:10 +0100 Subject: [PATCH] feat(ui): added section with disabled plugins --- lua/lazy/core/plugin.lua | 1 + lua/lazy/help.lua | 4 +++- lua/lazy/types.lua | 2 +- lua/lazy/view/render.lua | 3 +++ lua/lazy/view/sections.lua | 8 +++++++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 1fbab67..dd4ebfd 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -99,6 +99,7 @@ function Spec:add(plugin, results, is_dep) self.plugins[plugin.name] = plugin return results and table.insert(results, plugin.name) else + plugin._.kind = "disabled" self.disabled[plugin.name] = plugin self.plugins[plugin.name] = nil end diff --git a/lua/lazy/help.lua b/lua/lazy/help.lua index 2239b9a..599e2b4 100644 --- a/lua/lazy/help.lua +++ b/lua/lazy/help.lua @@ -38,7 +38,9 @@ function M.index(plugin) end function M.update() - vim.cmd.helptags(Config.plugins["lazy.nvim"].dir .. "/doc") + if Config.plugins["lazy.nvim"] then + vim.cmd.helptags(Config.plugins["lazy.nvim"].dir .. "/doc") + end local docs = Config.options.readme.root .. "/doc" vim.fn.mkdir(docs, "p") diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua index 3c5c5d1..c461c4c 100644 --- a/lua/lazy/types.lua +++ b/lua/lazy/types.lua @@ -1,5 +1,5 @@ ----@alias LazyPluginKind "normal"|"clean" +---@alias LazyPluginKind "normal"|"clean"|"disabled" ---@class LazyPluginState ---@field loaded? {[string]:string}|{time:number} diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 0784ff5..f5ce860 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -37,6 +37,7 @@ function M:update() self.plugins = vim.tbl_values(Config.plugins) vim.list_extend(self.plugins, vim.tbl_values(Config.to_clean)) + vim.list_extend(self.plugins, vim.tbl_values(Config.spec.disabled)) table.sort(self.plugins, function(a, b) return a.name < b.name end) @@ -99,6 +100,8 @@ function M:get_plugin(row) return plugin end end + elseif loc.kind == "disabled" then + return Config.spec.disabled[loc.name] else return Config.plugins[loc.name] end diff --git a/lua/lazy/view/sections.lua b/lua/lazy/view/sections.lua index d23cefd..8325332 100644 --- a/lua/lazy/view/sections.lua +++ b/lua/lazy/view/sections.lua @@ -83,7 +83,7 @@ return { }, { filter = function(plugin) - return not plugin._.installed + return not plugin._.installed and plugin._.kind ~= "disabled" end, title = "Not Installed", }, @@ -99,4 +99,10 @@ return { end, title = "Not Loaded", }, + { + filter = function(plugin) + return plugin._.kind == "disabled" + end, + title = "Disabled", + }, }