feat: add warning message when using PackerSync on snapshot branches
This commit is contained in:
parent
46590c3772
commit
7bb3afbb96
2 changed files with 44 additions and 3 deletions
|
|
@ -160,4 +160,38 @@ M.load_override = function(default_table, plugin_name)
|
|||
return default_table
|
||||
end
|
||||
|
||||
M.packer_sync = function(...)
|
||||
local git_exists, git = pcall(require, "nvchad.utils.git")
|
||||
local defaults_exists, defaults = pcall(require, "nvchad.utils.config")
|
||||
local packer_exists, packer = pcall(require, "packer")
|
||||
|
||||
if git_exists and defaults_exists then
|
||||
local current_branch_name = git.get_current_branch_name()
|
||||
|
||||
-- warn the user if we are on a snapshot branch
|
||||
if current_branch_name:match(defaults.snaps.base_snap_branch_name .. "(.+)" .. "$") then
|
||||
vim.api.nvim_echo({
|
||||
{ "WARNING: You are trying to use ", "WarningMsg" },
|
||||
{ "PackerSync" },
|
||||
{ " on a NvChadSnapshot. This will cause issues if NvChad dependencies contain "
|
||||
.. "any breaking changes! Plugin updates will not be included in this "
|
||||
.. "snapshot, so they will be lost after switching between snapshots! Would "
|
||||
.. "you still like to continue? [y/N]\n", "WarningMsg" }
|
||||
}, false, {})
|
||||
|
||||
local ans = vim.trim(string.lower(vim.fn.input("-> ")))
|
||||
|
||||
if ans ~= "y" then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if packer_exists then
|
||||
packer.sync(...)
|
||||
else
|
||||
error("Packer could not be loaded!")
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue