Merge branch 'main' into main

This commit is contained in:
Vladimir Shvets 2025-03-08 05:21:03 +07:00 committed by GitHub
commit 625d5b4011
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 541 additions and 301 deletions

View file

@ -83,6 +83,7 @@ end
---@param modname string
---@param source LazyExtraSource
function M.get_extra(source, modname)
LazyVim.plugin.handle_defaults = false
local enabled = vim.tbl_contains(M.state, modname)
local spec = Plugin.Spec.new(nil, { optional = true, pkg = false })
spec:parse({ import = modname })
@ -248,6 +249,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,7 +267,7 @@ 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",
})

View file

@ -55,12 +55,33 @@ function M.has(plugin)
return M.get_plugin(plugin) ~= nil
end
--- Checks if the extras is enabled:
--- * If the module was imported
--- * If the module was added by LazyExtras
--- * If the module is in the user's lazy imports
---@param extra string
function M.has_extra(extra)
local Config = require("lazyvim.config")
local modname = "lazyvim.plugins.extras." .. extra
return vim.tbl_contains(require("lazy.core.config").spec.modules, modname)
or vim.tbl_contains(Config.json.data.extras, modname)
local LazyConfig = require("lazy.core.config")
-- check if it was imported already
if vim.tbl_contains(LazyConfig.spec.modules, modname) then
return true
end
-- check if it was added by LazyExtras
if vim.tbl_contains(Config.json.data.extras, modname) then
return true
end
-- check if it's in the imports
local spec = LazyConfig.options.spec
if type(spec) == "table" then
for _, s in ipairs(spec) do
if type(s) == "table" and s.import == modname then
return true
end
end
end
return false
end
---@param fn fun()
@ -265,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

@ -97,6 +97,8 @@ function M.migrate()
return vim.tbl_contains(ai, name) and ("lazyvim.plugins.extras.ai." .. name) or extra
end)
end, json.data.extras or {})
elseif json.data.version == 7 then
json.data.install_version = 7
end
M.save()

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

@ -5,6 +5,7 @@ local M = {}
---@type string[]
M.core_imports = {}
M.handle_defaults = true
M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" }
@ -79,7 +80,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 M.handle_defaults and 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."