refactor: rewrite stable channel commit pinning
This commit is contained in:
@@ -0,0 +1 @@
|
||||
lua/lazy_snapshot.lua
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "e89df176e8b38e931b7e71a470f923a317976d86" },
|
||||
"LuaSnip": { "branch": "master", "commit": "508b41fb7b2a7f06522f96eb7742d21f025a8512" },
|
||||
"SchemaStore.nvim": { "branch": "main", "commit": "c55c35929dd4e670af7ab6e2e197a4687baa2076" },
|
||||
"aerial.nvim": { "branch": "master", "commit": "3eafbd28ae573fa665121a6e058a450cf3fe8573" },
|
||||
"alpha-nvim": { "branch": "main", "commit": "21a0f2520ad3a7c32c0822f943368dc063a569fb" },
|
||||
"better-escape.nvim": { "branch": "master", "commit": "6fed33809cde3b416087fc540ad9eb17ec470193" },
|
||||
"bufdelete.nvim": { "branch": "master", "commit": "f79e9d186b42fba5f1b1362006e7c70240db97a4" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "484fb38b8f493ceeebf4e6fc499ebe41e10aae25" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "d4f8c01280413919349f5df7daccd0c172143d7c" },
|
||||
"heirline.nvim": { "branch": "master", "commit": "556666aabb57c227cbb14a996b30b2934e5ff7b1" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "c4c203c3e8a595bc333abaf168fcb10c13ed5fb7" },
|
||||
"indent-o-matic": { "branch": "master", "commit": "749b7cbae2d52aa1f65b6a2cd7b879a0b52ac3a1" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "ef87c24e8ede2a94cbeaea1667eaeb7f8ed40dc0" },
|
||||
"lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "3751eb5c56c67b51e68a1f4a0da28ae74ab771c1" },
|
||||
"mason-null-ls.nvim": { "branch": "main", "commit": "c4b4a6fe3cb8d8590b831c22b3475166dc9a894e" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "d6cb770928b5cb9a6e3880d6bbb58858c1deeb18" },
|
||||
"mason.nvim": { "branch": "main", "commit": "a4ebe1f14ba31242cd09f9e0709d5b1f9d2bcecb" },
|
||||
"neo-tree.nvim": { "branch": "v2.x", "commit": "3b41f0d17139bb156f1acd907608f63e0e307caf" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "258b83f48405c6b530c09dd96950693664dc6bc0" },
|
||||
"neovim-session-manager": { "branch": "master", "commit": "f8c85da390c5d1ad3bfd229ac2ed805c5742263d" },
|
||||
"nui.nvim": { "branch": "main", "commit": "257da38029d3859ed111804f9d4e95b0fa993a31" },
|
||||
"null-ls.nvim": { "branch": "main", "commit": "915558963709ea17c5aa246ca1c9786bfee6ddb4" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "f00eb3b766c370cb34fdabc29c760338ba9e4c6c" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "a9c701fa7e12e9257b3162000e5288a75d280c28" },
|
||||
"nvim-colorizer.lua": { "branch": "master", "commit": "760e27df4dd966607e8fb7fd8b6b93e3c7d2e193" },
|
||||
"nvim-dap": { "branch": "master", "commit": "700a3c7d6fbe5b07bee74e9952b456120d355c47" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "f2206de65ea39093e3f13992507fc985c17aa763" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "7b98aadc6e85db4fc3af6c1ec22c4774d965506e" },
|
||||
"nvim-notify": { "branch": "master", "commit": "b005821516f1f37801a73067afd1cef2dbc4dfe8" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "d8c84521dc9f407f88dfca35b9572c6532207a4a" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "fdefe46c6807441460f11f11a167a2baf8e4534b" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "4a42b30376c1bd625ab5016c2079631d531d797a" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "7f55bc36eddec87597167a97de5b690997edaf7d" },
|
||||
"nvim-window-picker": { "branch": "main", "commit": "5902827d0e338890a22849e2f18dc80d1cc1a8db" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "9d81624fbcedd3dd43b38d7e13a1e7b3f873d8cd" },
|
||||
"smart-splits.nvim": { "branch": "master", "commit": "fdd158ce7554dc830fb86e0fe952cd9476cdf726" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "fab3e2212e206f4f8b3bbaa656e129443c9b802e" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "04af51dbfb17c2afa0b8d82b0e842e0638201ca9" },
|
||||
"toggleterm.nvim": { "branch": "main", "commit": "b02a1674bd0010d7982b056fd3df4f717ff8a57a" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "b7e0b1f16c20bc1ea0515851bc5740d1c1f18444" }
|
||||
}
|
||||
+5
-1
@@ -18,13 +18,17 @@ if not vim.loop.fs_stat(lazypath) then
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
local spec = astronvim.updater.options.pin_plugins and { { import = astronvim.updater.snapshot.module } } or {}
|
||||
|
||||
local user_plugins = astronvim.user_opts "plugins"
|
||||
for _, config_dir in ipairs(astronvim.supported_configs) do
|
||||
if vim.fn.isdirectory(config_dir .. "/lua/user/plugins") == 1 then user_plugins = { import = "user.plugins" } end
|
||||
end
|
||||
|
||||
vim.list_extend(spec, { { import = "plugins" }, user_plugins })
|
||||
|
||||
require("lazy").setup(astronvim.user_opts("lazy", {
|
||||
spec = { { import = "plugins" }, user_plugins },
|
||||
spec = spec,
|
||||
defaults = { lazy = true },
|
||||
install = { colorscheme = { astronvim.user_opts("colorscheme", false, false), "astronvim" } },
|
||||
performance = {
|
||||
|
||||
+4
-12
@@ -226,21 +226,13 @@ function astronvim.user_opts(module, default, extend)
|
||||
return default
|
||||
end
|
||||
|
||||
--- Helper function to create a plugin with default AstroNvim features such as pinning commit on stable and creating the config function
|
||||
--- Helper function to create a plugin with default AstroNvim features such as creating the default config function
|
||||
-- @param plugin a parameter specification for the Lazy plugin manager
|
||||
-- @return the plugin with a commit and branch set if it should be pinned and a config function if it has a default_config
|
||||
-- @return the plugin a config function if it has a default_config
|
||||
function astronvim.plugin(plugin)
|
||||
if type(plugin) ~= "table" then plugin = { plugin } end
|
||||
if plugin.default_config and not plugin.config then
|
||||
if type(plugin) == "table" and plugin.default_config and not plugin.config then
|
||||
plugin.config = function(spec, opts) spec.default_config(opts) end
|
||||
end
|
||||
if astronvim.updater.snapshot then
|
||||
local pin = astronvim.updater.snapshot[plugin[1]:match "/([^/]*)$"]
|
||||
if pin and pin.commit and not (plugin.version or plugin.commit) then
|
||||
plugin.commit = pin.commit
|
||||
plugin.branch = pin.branch
|
||||
end
|
||||
end
|
||||
return plugin
|
||||
end
|
||||
|
||||
@@ -419,7 +411,7 @@ function astronvim.cmd(cmd, show_error)
|
||||
if vim.fn.has "win32" == 1 then cmd = { "cmd.exe", "/C", cmd } end
|
||||
local result = vim.fn.system(cmd)
|
||||
local success = vim.api.nvim_get_vvar "shell_error" == 0
|
||||
if not success and (show_error == nil and true or show_error) then
|
||||
if not success and (show_error == nil or show_error) then
|
||||
vim.api.nvim_err_writeln("Error running command: " .. cmd .. "\nError message:\n" .. result)
|
||||
end
|
||||
return success and result:gsub("[\27\155][][()#;?%d]*[A-PRZcf-ntqry=><~]", "") or nil
|
||||
|
||||
+33
-12
@@ -9,7 +9,6 @@
|
||||
-- @copyright 2022
|
||||
-- @license GNU General Public License v3.0
|
||||
|
||||
local fn = vim.fn
|
||||
local git = require "core.utils.git"
|
||||
--- Updater settings overridden with any user provided configuration
|
||||
local options = astronvim.user_opts("updater", {
|
||||
@@ -24,17 +23,37 @@ if options.branch and options.branch ~= "main" then options.channel = "nightly"
|
||||
if astronvim.install.is_stable ~= nil then options.channel = astronvim.install.is_stable and "stable" or "nightly" end
|
||||
|
||||
astronvim.updater = { options = options }
|
||||
-- if the channel is stable or the user has chosen to pin the system plugins
|
||||
if options.pin_plugins == nil and options.channel == "stable" or options.pin_plugins then
|
||||
-- load the current packer snapshot from the installation home location
|
||||
local loaded, snapshot = pcall(fn.readfile, astronvim.install.home .. "/lazy-snapshot.json")
|
||||
if loaded then
|
||||
-- decode the snapshot JSON and save it to a variable
|
||||
loaded, snapshot = pcall(fn.json_decode, snapshot)
|
||||
astronvim.updater.snapshot = type(snapshot) == "table" and snapshot or nil
|
||||
-- set default pin_plugins for stable branch
|
||||
if options.pin_plugins == nil and options.channel == "stable" then options.pin_plugins = true end
|
||||
|
||||
astronvim.updater.snapshot = {
|
||||
module = "lazy_snapshot",
|
||||
path = vim.fn.stdpath "config" .. "/lua/lazy_snapshot.lua",
|
||||
}
|
||||
|
||||
--- Helper function to generate AstroNvim snapshots
|
||||
-- @param write boolean whether or not to write to the snapshot file (default: false)
|
||||
-- @return the plugin specification table of the snapshot
|
||||
function astronvim.updater.generate_snapshot(write)
|
||||
local file
|
||||
local plugins = assert(require("lazy").plugins())
|
||||
local function git_cmd(dir, args)
|
||||
return astronvim.trim_or_nil(assert(astronvim.cmd("git -C " .. dir .. " " .. args, false)))
|
||||
end
|
||||
-- if there is an error loading the snapshot, print an error
|
||||
if not loaded then vim.api.nvim_err_writeln "Error loading packer snapshot" end
|
||||
if write == true then
|
||||
file = assert(io.open(astronvim.updater.snapshot.path, "w"))
|
||||
file:write "return {\n"
|
||||
end
|
||||
local snapshot = vim.tbl_map(function(plugin)
|
||||
plugin = { plugin[1], commit = git_cmd(plugin.dir, "rev-parse HEAD") }
|
||||
if file then file:write((" { %q, commit = %q },\n"):format(plugin[1], plugin.commit)) end
|
||||
return plugin
|
||||
end, plugins)
|
||||
if file then
|
||||
file:write "}"
|
||||
file:close()
|
||||
end
|
||||
return snapshot
|
||||
end
|
||||
|
||||
--- Get the current AstroNvim version
|
||||
@@ -221,7 +240,8 @@ function astronvim.updater.update()
|
||||
{ git.current_version(), "String" },
|
||||
{ "!\n", "Title" },
|
||||
{
|
||||
options.auto_quit and "AstroNvim will now quit.\n\n" or "Please restart.\n\n",
|
||||
options.auto_quit and "AstroNvim will now update plugins and quit.\n\n"
|
||||
or "After plugins update, please restart.\n\n",
|
||||
"WarningMsg",
|
||||
},
|
||||
}
|
||||
@@ -236,6 +256,7 @@ function astronvim.updater.update()
|
||||
vim.api.nvim_create_autocmd("User", { pattern = "AstroUpdateComplete", command = "quitall" })
|
||||
end
|
||||
|
||||
require("lazy").sync { wait = true }
|
||||
astronvim.event "UpdateComplete"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
return {
|
||||
{ "jose-elias-alvarez/null-ls.nvim", commit = "915558963709ea17c5aa246ca1c9786bfee6ddb4" },
|
||||
{ "folke/neodev.nvim", commit = "258b83f48405c6b530c09dd96950693664dc6bc0" },
|
||||
{ "NvChad/nvim-colorizer.lua", commit = "760e27df4dd966607e8fb7fd8b6b93e3c7d2e193" },
|
||||
{ "rebelot/heirline.nvim", commit = "b07ae7e499fecc263f38d1db7feeb2da227df370" },
|
||||
{ "numToStr/Comment.nvim", commit = "e89df176e8b38e931b7e71a470f923a317976d86" },
|
||||
{ "nvim-telescope/telescope.nvim", commit = "1ba7278cf08da8048e7f589ef6b65a39fd3e4dbf" },
|
||||
{ "nvim-lua/plenary.nvim", commit = "1c7e3e6b0f4dd5a174fcea9fda8a4d7de593b826" },
|
||||
{ "williamboman/mason.nvim", commit = "4d734aee41efce4f1a4be7619ad040b53237042e" },
|
||||
{ "Shatur/neovim-session-manager", commit = "f8c85da390c5d1ad3bfd229ac2ed805c5742263d" },
|
||||
{ "MunifTanjim/nui.nvim", commit = "257da38029d3859ed111804f9d4e95b0fa993a31" },
|
||||
{ "mfussenegger/nvim-dap", commit = "700a3c7d6fbe5b07bee74e9952b456120d355c47" },
|
||||
{ "mrjones2014/smart-splits.nvim", commit = "fdd158ce7554dc830fb86e0fe952cd9476cdf726" },
|
||||
{ "L3MON4D3/LuaSnip", commit = "5d57303efde86fcb0959c52b1a6d40f923940f34" },
|
||||
{ "hrsh7th/cmp-nvim-lsp", commit = "59224771f91b86d1de12570b4070fe4ad7cd1eeb" },
|
||||
{ "windwp/nvim-ts-autotag", commit = "fdefe46c6807441460f11f11a167a2baf8e4534b" },
|
||||
{ "famiu/bufdelete.nvim", commit = "f79e9d186b42fba5f1b1362006e7c70240db97a4" },
|
||||
{ "rcarriga/nvim-dap-ui", commit = "b80227ea56a48177786904f6322abc8b2dc0bc36" },
|
||||
{ "rcarriga/nvim-notify", commit = "b005821516f1f37801a73067afd1cef2dbc4dfe8" },
|
||||
{ "s1n7ax/nvim-window-picker", commit = "5902827d0e338890a22849e2f18dc80d1cc1a8db" },
|
||||
{ "nvim-neo-tree/neo-tree.nvim", commit = "8238865e1d9c61f1a260c290653f2c419503e0a9" },
|
||||
{ "hrsh7th/cmp-path", commit = "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
{ "rafamadriz/friendly-snippets", commit = "484fb38b8f493ceeebf4e6fc499ebe41e10aae25" },
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", commit = "fab3e2212e206f4f8b3bbaa656e129443c9b802e" },
|
||||
{ "nvim-treesitter/nvim-treesitter", commit = "9a257d989a526c413a28c252c4ec9113a7d35a28" },
|
||||
{ "lewis6991/gitsigns.nvim", commit = "f8a1e2a8c8bfb79fe2ee7e61bb76797350187efa" },
|
||||
{ "onsails/lspkind.nvim", commit = "c68b3a003483cf382428a43035079f78474cd11e" },
|
||||
{ "folke/which-key.nvim", commit = "16ed12a8493628c377606da2ebac50d80736ed37" },
|
||||
{ "neovim/nvim-lspconfig", commit = "f0221821d8ceed70f0525a2c35380ba56672e107" },
|
||||
{ "jay-babu/mason-nvim-dap.nvim", commit = "d6cb770928b5cb9a6e3880d6bbb58858c1deeb18" },
|
||||
{ "williamboman/mason-lspconfig.nvim", commit = "3751eb5c56c67b51e68a1f4a0da28ae74ab771c1" },
|
||||
{ "hrsh7th/nvim-cmp", commit = "a9c701fa7e12e9257b3162000e5288a75d280c28" },
|
||||
{ "jay-babu/mason-null-ls.nvim", commit = "c4b4a6fe3cb8d8590b831c22b3475166dc9a894e" },
|
||||
{ "goolord/alpha-nvim", commit = "21a0f2520ad3a7c32c0822f943368dc063a569fb" },
|
||||
{ "JoosepAlviste/nvim-ts-context-commentstring", commit = "4a42b30376c1bd625ab5016c2079631d531d797a" },
|
||||
{ "nvim-tree/nvim-web-devicons", commit = "6c38926351372ea87034dec26182b62c835ff3bc" },
|
||||
{ "stevearc/dressing.nvim", commit = "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" },
|
||||
{ "b0o/SchemaStore.nvim", commit = "2af488a5c74e44215349258a4c9e74bea8e061be" },
|
||||
{ "Darazaki/indent-o-matic", commit = "749b7cbae2d52aa1f65b6a2cd7b879a0b52ac3a1" },
|
||||
{ "stevearc/aerial.nvim", commit = "3eafbd28ae573fa665121a6e058a450cf3fe8573" },
|
||||
{ "lukas-reineke/indent-blankline.nvim", commit = "c4c203c3e8a595bc333abaf168fcb10c13ed5fb7" },
|
||||
{ "folke/lazy.nvim", commit = "0741d6231917ef77cd5f69a9b1aacc402a676dd1" },
|
||||
{ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
{ "saadparwaiz1/cmp_luasnip", commit = "18095520391186d634a0045dacaa346291096566" },
|
||||
{ "akinsho/toggleterm.nvim", commit = "528d6375745dc3c5db6ab7d5fba0ddbdec5bf4e0" },
|
||||
{ "windwp/nvim-autopairs", commit = "f00eb3b766c370cb34fdabc29c760338ba9e4c6c" },
|
||||
{ "max397574/better-escape.nvim", commit = "6fed33809cde3b416087fc540ad9eb17ec470193" },
|
||||
}
|
||||
Reference in New Issue
Block a user