feat(extras): allow recommended to be the args for LazyVim.extras.wants

This commit is contained in:
Folke Lemaitre
2024-06-05 23:35:14 +02:00
parent 393aa44e66
commit 502602e4a2
2 changed files with 7 additions and 2 deletions

View File

@ -37,7 +37,9 @@ M.ns = vim.api.nvim_create_namespace("lazyvim.extras")
---@type string[]
M.state = nil
---@param opts {ft?: string|string[], root?: string|string[]}
---@alias WantsOpts {ft?: string|string[], root?: string|string[]}
---@param opts WantsOpts
---@return boolean
function M.wants(opts)
if opts.ft then
@ -105,10 +107,12 @@ function M.get_extra(source, modname)
table.sort(plugins)
table.sort(optional)
---@type boolean|(fun():boolean?)|nil
---@type boolean|(fun():boolean?)|nil|WantsOpts
local recommended = require(modname).recommended or false
if type(recommended) == "function" then
recommended = recommended() or false
elseif type(recommended) == "table" then
recommended = M.wants(recommended)
end
---@type LazyExtra

View File

@ -21,6 +21,7 @@ local plugins = {
{ "folke/lazy.nvim" },
"williamboman/mason-lspconfig.nvim",
"williamboman/mason.nvim",
"nvim-treesitter/nvim-treesitter",
}
local function main()