feat(defaults): new installs now default to snacks picker/explorer. Existing installs don't change.

This commit is contained in:
Folke Lemaitre 2025-02-08 15:23:30 +01:00
parent b4c24a3fe8
commit 25d90b54a3
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 19 additions and 7 deletions

View file

@ -136,18 +136,19 @@ local defaults = {
} }
M.json = { M.json = {
version = 7, version = 8,
loaded = false,
path = vim.g.lazyvim_json or vim.fn.stdpath("config") .. "/lazyvim.json", path = vim.g.lazyvim_json or vim.fn.stdpath("config") .. "/lazyvim.json",
data = { data = {
version = nil, ---@type string? version = nil, ---@type number?
install_version = nil, ---@type number?
news = {}, ---@type table<string, string> news = {}, ---@type table<string, string>
extras = {}, ---@type string[] extras = {}, ---@type string[]
}, },
} }
M.json_loaded = false
function M.json.load() function M.json.load()
M.json_loaded = true M.json.loaded = true
local f = io.open(M.json.path, "r") local f = io.open(M.json.path, "r")
if f then if f then
local data = f:read("*a") local data = f:read("*a")
@ -159,6 +160,8 @@ function M.json.load()
LazyVim.json.migrate() LazyVim.json.migrate()
end end
end end
else
M.json.data.install_version = M.json.version
end end
end end
@ -334,8 +337,8 @@ function M.get_defaults()
---@type table<string, LazyVimDefault[]> ---@type table<string, LazyVimDefault[]>
local checks = { local checks = {
picker = { picker = {
{ name = "fzf", extra = "editor.fzf" },
{ name = "snacks", extra = "editor.snacks_picker" }, { name = "snacks", extra = "editor.snacks_picker" },
{ name = "fzf", extra = "editor.fzf" },
{ name = "telescope", extra = "editor.telescope" }, { name = "telescope", extra = "editor.telescope" },
}, },
cmp = { cmp = {
@ -343,10 +346,17 @@ function M.get_defaults()
{ name = "nvim-cmp", extra = "coding.nvim-cmp" }, { name = "nvim-cmp", extra = "coding.nvim-cmp" },
}, },
explorer = { explorer = {
{ name = "neo-tree", extra = "editor.neo-tree" },
{ name = "snacks", extra = "editor.snacks_explorer" }, { name = "snacks", extra = "editor.snacks_explorer" },
{ name = "neo-tree", extra = "editor.neo-tree" },
}, },
} }
-- existing installs keep their defaults
if (LazyVim.config.json.data.install_version or 7) < 8 then
table.insert(checks.picker, 1, table.remove(checks.picker, 2))
table.insert(checks.explorer, 1, table.remove(checks.explorer, 2))
end
default_extras = {} default_extras = {}
for name, check in pairs(checks) do for name, check in pairs(checks) do
local valid = {} ---@type string[] local valid = {} ---@type string[]

View file

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

View file

@ -81,7 +81,7 @@ end
function M.fix_imports() function M.fix_imports()
local defaults ---@type table<string, LazyVimDefault> local defaults ---@type table<string, LazyVimDefault>
Plugin.Spec.import = LazyVim.inject.args(Plugin.Spec.import, function(_, spec) Plugin.Spec.import = LazyVim.inject.args(Plugin.Spec.import, function(_, spec)
if LazyVim.config.json_loaded then if LazyVim.config.json.loaded then
-- extra disabled by defaults? -- extra disabled by defaults?
defaults = defaults or LazyVim.config.get_defaults() defaults = defaults or LazyVim.config.get_defaults()
local def = defaults[spec.import] local def = defaults[spec.import]