feat(ui): show optional plugins in a different color

This commit is contained in:
Folke Lemaitre 2023-10-12 00:20:32 +02:00
parent c38c3bf407
commit 8597c2085f
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 24 additions and 2 deletions

View file

@ -64,6 +64,7 @@ return {
-- Telescope integration -- Telescope integration
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
optional = true,
opts = function() opts = function()
Util.on_load("telescope.nvim", function() Util.on_load("telescope.nvim", function()
require("telescope").load_extension("aerial") require("telescope").load_extension("aerial")

View file

@ -11,6 +11,7 @@ local Util = require("lazyvim.util")
---@field managed boolean ---@field managed boolean
---@field row? number ---@field row? number
---@field plugins string[] ---@field plugins string[]
---@field optional string[]
---@class lazyvim.util.extras ---@class lazyvim.util.extras
local M = {} local M = {}
@ -43,12 +44,25 @@ function M.get()
return vim.tbl_map(function(extra) return vim.tbl_map(function(extra)
local modname = "lazyvim.plugins.extras." .. extra local modname = "lazyvim.plugins.extras." .. extra
local enabled = vim.tbl_contains(M.state, modname) local enabled = vim.tbl_contains(M.state, modname)
local spec = Plugin.Spec.new({ import = "lazyvim.plugins.extras." .. extra }, { optional = false }) local spec = Plugin.Spec.new({ import = "lazyvim.plugins.extras." .. extra }, { optional = true })
local plugins = {} ---@type string[]
local optional = {} ---@type string[]
for _, p in pairs(spec.plugins) do
if p.optional then
optional[#optional + 1] = p.name
else
plugins[#plugins + 1] = p.name
end
end
table.sort(plugins)
table.sort(optional)
return { return {
name = extra, name = extra,
enabled = enabled, enabled = enabled,
managed = vim.tbl_contains(Config.json.data.extras, extra) or not enabled, managed = vim.tbl_contains(Config.json.data.extras, extra) or not enabled,
plugins = vim.tbl_keys(spec.plugins), plugins = plugins,
optional = optional,
} }
end, extras) end, extras)
end end
@ -151,6 +165,10 @@ end
function X:render() function X:render()
self.text:nl():nl():append("LazyVim Extras", "LazyH1"):nl():nl() self.text:nl():nl():append("LazyVim Extras", "LazyH1"):nl():nl()
self.text self.text
:append("This is a list of all enabled/disabled LazyVim extras.", "LazyComment")
:nl()
:append("Each extra shows the required and optional plugins it may install.", "LazyComment")
:nl()
:append("Enable/disable extras with the ", "LazyComment") :append("Enable/disable extras with the ", "LazyComment")
:append("<x>", "LazySpecial") :append("<x>", "LazySpecial")
:append(" key", "LazyComment") :append(" key", "LazyComment")
@ -178,6 +196,9 @@ function X:extra(extra)
for _, plugin in ipairs(extra.plugins) do for _, plugin in ipairs(extra.plugins) do
self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonPlugin") self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonPlugin")
end end
for _, plugin in ipairs(extra.optional) do
self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonRequire")
end
self.text:nl() self.text:nl()
end end