migrate to lazy.nvim
This commit is contained in:
@@ -116,49 +116,12 @@ M.load_override = function(options_table, name)
|
||||
return merge_tb("force", options_table, plugin_options)
|
||||
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
|
||||
|
||||
M.lazy_load = function(plugin)
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
|
||||
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}),
|
||||
callback = function()
|
||||
local file = vim.fn.expand "%"
|
||||
local condition = file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||
local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= ""
|
||||
|
||||
if condition then
|
||||
vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin)
|
||||
@@ -166,14 +129,15 @@ M.lazy_load = function(plugin)
|
||||
-- dont defer for treesitter as it will show slow highlighting
|
||||
-- This deferring only happens only when we do "nvim filename"
|
||||
if plugin ~= "nvim-treesitter" then
|
||||
vim.defer_fn(function()
|
||||
require("packer").loader(plugin)
|
||||
vim.schedule(function()
|
||||
require("lazy").load { plugins = plugin }
|
||||
|
||||
if plugin == "nvim-lspconfig" then
|
||||
vim.cmd "silent! do FileType"
|
||||
end
|
||||
end, 0)
|
||||
else
|
||||
require("packer").loader(plugin)
|
||||
require("lazy").load { plugins = plugin }
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
Reference in New Issue
Block a user