feat(extras): big rework of default extras

This commit is contained in:
Folke Lemaitre 2025-02-08 15:04:46 +01:00
parent 0416376733
commit 525377dee9
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
13 changed files with 222 additions and 200 deletions

View file

@ -248,6 +248,9 @@ end
---@param extra LazyExtra
function X:extra(extra)
local defaults = LazyVim.config.get_defaults()
local def = defaults[extra.module]
local origin = def and (def.origin or "user") or nil
if not extra.managed then
---@type LazyExtra[]
local parents = {}
@ -263,11 +266,12 @@ function X:extra(extra)
self:diagnostic({
message = "Required by " .. table.concat(pp, ", "),
})
elseif vim.tbl_contains(LazyVim.plugin.core_imports, extra.module) then
elseif vim.tbl_contains(LazyVim.plugin.core_imports, extra.module) or origin == "default" then
self:diagnostic({
message = "This extra is included by default",
})
else
dd(origin)
self:diagnostic({
message = "Not managed by LazyExtras (config)",
severity = vim.diagnostic.severity.WARN,

View file

@ -286,13 +286,4 @@ function M.memoize(fn)
end
end
---@return "nvim-cmp" | "blink.cmp"
function M.cmp_engine()
vim.g.lazyvim_cmp = vim.g.lazyvim_cmp or "auto"
if vim.g.lazyvim_cmp == "auto" then
return LazyVim.has_extra("coding.nvim-cmp") and "nvim-cmp" or "blink.cmp"
end
return vim.g.lazyvim_cmp
end
return M

View file

@ -28,10 +28,6 @@ function M.register(picker)
return true
end
if M.picker and M.picker.name ~= M.want() then
M.picker = nil
end
if M.picker and M.picker.name ~= picker.name then
LazyVim.warn(
"`LazyVim.pick`: picker already set to `" .. M.picker.name .. "`,\nignoring new picker `" .. picker.name .. "`"
@ -42,17 +38,6 @@ function M.register(picker)
return true
end
---@return "telescope" | "fzf" | "snacks"
function M.want()
vim.g.lazyvim_picker = vim.g.lazyvim_picker or "auto"
if vim.g.lazyvim_picker == "auto" then
return LazyVim.has_extra("editor.snacks_picker") and "snacks"
or LazyVim.has_extra("editor.telescope") and "telescope"
or "fzf"
end
return vim.g.lazyvim_picker
end
---@param command? string
---@param opts? lazyvim.util.pick.Opts
function M.open(command, opts)

View file

@ -79,7 +79,16 @@ function M.lazy_file()
end
function M.fix_imports()
local defaults ---@type table<string, LazyVimDefault>
Plugin.Spec.import = LazyVim.inject.args(Plugin.Spec.import, function(_, spec)
if LazyVim.config.json_loaded then
-- extra disabled by defaults?
defaults = defaults or LazyVim.config.get_defaults()
local def = defaults[spec.import]
if def and def.enabled == false then
return false
end
end
local dep = M.deprecated_extras[spec and spec.import]
if dep then
dep = dep .. "\n" .. "Please remove the extra from `lazyvim.json` to hide this warning."