bootstrap chadrc template before packer boostrap

This commit is contained in:
siduck 2022-12-24 23:44:00 +05:30
parent 54280a3e2a
commit ddeba3c01b
2 changed files with 5 additions and 2 deletions

View file

@ -14,6 +14,7 @@ local fn = vim.fn
local install_path = fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim" local install_path = fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then if fn.empty(fn.glob(install_path)) > 0 then
require("core.bootstrap").chadrc_template()
require("core.bootstrap").packer(install_path) require("core.bootstrap").packer(install_path)
end end

View file

@ -14,19 +14,22 @@ M.packer = function(install_path)
vim.cmd "PackerSync" vim.cmd "PackerSync"
end end
M.install_template = function() M.chadrc_template = function()
if not vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] then if not vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] then
local input = vim.fn.input "Do you want to install chadrc template? (y/n) : " local input = vim.fn.input "Do you want to install chadrc template? (y/n) : "
vim.cmd "redraw|echo ''"
if input == "y" then if input == "y" then
-- clone example_config repo -- clone example_config repo
local example_config_url = "https://github.com/NvChad/example_config" local example_config_url = "https://github.com/NvChad/example_config"
print "cloning chadrc starter template repo...." print "cloning chadrc starter template repo...."
vim.fn.system { "git", "clone", "--depth", "1", example_config_url, vim.fn.stdpath "config" .. "/lua/custom" } vim.fn.system { "git", "clone", "--depth", "1", example_config_url, vim.fn.stdpath "config" .. "/lua/custom" }
vim.cmd "redraw|echo ''"
-- delete .git from that repo -- delete .git from that repo
vim.loop.fs_rmdir(vim.fn.stdpath "config" .. "/lua/custom/.git") vim.loop.fs_rmdir(vim.fn.stdpath "config" .. "/lua/custom/.git")
vim.notify "successfully installed chadrc template!" vim.notify "successfully installed chadrc template!"
vim.cmd "redraw|echo ''"
end end
end end
end end
@ -35,7 +38,6 @@ end
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "PackerComplete", pattern = "PackerComplete",
callback = function() callback = function()
M.install_template()
require("base46").load_all_highlights() require("base46").load_all_highlights()
vim.cmd "bw | silent! MasonInstallAll" -- close packer window vim.cmd "bw | silent! MasonInstallAll" -- close packer window