From 985217b93f9274d40c408ca26c6152cc5bcf8f0b Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 30 Apr 2022 23:37:31 +0530 Subject: [PATCH] add: Packer snapshot feature (#721) --- lua/core/default_config.lua | 1 + lua/core/mappings.lua | 16 ++++++++++++++++ lua/plugins/packerInit.lua | 3 +++ 3 files changed, 20 insertions(+) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 04a1a1f5..72dbf7ae 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -31,6 +31,7 @@ M.plugins = { options = { packer = { init_file = "plugins.packerInit", + snapshot = nil, }, lspconfig = { setup_lspconf = "", -- path of lspconfig file diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index bd736c34..99a3d262 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -68,6 +68,22 @@ local packer_cmd = function(callback) end end +-- snapshot stuff +user_cmd("PackerSnapshot", function(info) + require "plugins" + require("packer").snapshot(info.args) +end, { nargs = "+" }) + +user_cmd("PackerSnapshotDelete", function(info) + require "plugins" + require("packer.snapshot").delete(info.args) +end, { nargs = "+" }) + +user_cmd("PackerSnapshotRollback", function(info) + require "plugins" + require("packer").rollback(info.args) +end, { nargs = "+" }) + user_cmd("PackerClean", packer_cmd "clean", {}) user_cmd("PackerCompile", packer_cmd "compile", {}) user_cmd("PackerInstall", packer_cmd "install", {}) diff --git a/lua/plugins/packerInit.lua b/lua/plugins/packerInit.lua index cafdd4fd..88be509b 100644 --- a/lua/plugins/packerInit.lua +++ b/lua/plugins/packerInit.lua @@ -27,6 +27,8 @@ if not present then end end +local user_snapshot = require("core.utils").load_config().snapshot + packer.init { display = { open_fn = function() @@ -39,6 +41,7 @@ packer.init { }, auto_clean = true, compile_on_sync = true, + snapshot = user_snapshot, } return packer