Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(updater): simplify plugin snapshot approach #607

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 5 additions & 8 deletions lua/core/utils/updater.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ local fn = vim.fn
local git = require "core.utils.git"
local options = astronvim.user_plugin_opts(
"updater",
{ remote = "origin", branch = "main", channel = "nightly", pin_plugins = true, show_changelog = true }
{ remote = "origin", branch = "main", channel = "nightly", show_changelog = true }
)

astronvim.updater = { options = options }
options.pin_plugins = options.pin_plugins == true and options.channel == "stable" and git.current_version()
or options.pin_plugins
if type(options.pin_plugins) == "string" then
local loaded, snapshot_file = pcall(fn.readfile, fn.stdpath "config" .. "/snapshots/" .. options.pin_plugins)
local snapshot
if options.pin_plugins == nil and options.channel == "stable" or options.pin_plugins then
local loaded, snapshot = pcall(fn.readfile, fn.stdpath "config" .. "/packer_snapshot")
if loaded then
loaded, snapshot = pcall(fn.json_decode, snapshot_file)
loaded, snapshot = pcall(fn.json_decode, snapshot)
astronvim.updater.snapshot = type(snapshot) == "table" and snapshot or nil
end
if not loaded then
vim.api.nvim_err_writeln("Error loading snapshot: " .. options.pin_plugins)
vim.api.nvim_err_writeln "Error loading packer snapshot"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lua/user_example/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local config = {
version = "latest", -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY)
branch = "main", -- branch name (NIGHTLY ONLY)
commit = nil, -- commit hash (NIGHTLY ONLY)
pin_plugins = true, -- true, false, or a string for a specific AstroNvim snapshot to use (true will only track the current version if channel is "stable")
pin_plugins = nil, -- nil, true, false (nil will pin plugins on stable only)
skip_prompts = false, -- skip prompts about breaking changes
show_changelog = true, -- show the changelog after performing an update
-- remotes = { -- easily add new remotes to track
Expand Down
File renamed without changes.