From ddeba3c01b26f5aa38773eeb3515cd8fc8c9e746 Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 24 Dec 2022 23:44:00 +0530 Subject: [PATCH] bootstrap chadrc template before packer boostrap --- init.lua | 1 + lua/core/bootstrap.lua | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 80dc54f..9ef65d8 100644 --- a/init.lua +++ b/init.lua @@ -14,6 +14,7 @@ local fn = vim.fn local install_path = fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim" if fn.empty(fn.glob(install_path)) > 0 then + require("core.bootstrap").chadrc_template() require("core.bootstrap").packer(install_path) end diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index 8800ab9..8502f4b 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -14,19 +14,22 @@ M.packer = function(install_path) vim.cmd "PackerSync" end -M.install_template = function() +M.chadrc_template = function() 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) : " + vim.cmd "redraw|echo ''" if input == "y" then -- clone example_config repo local example_config_url = "https://github.com/NvChad/example_config" print "cloning chadrc starter template repo...." 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 vim.loop.fs_rmdir(vim.fn.stdpath "config" .. "/lua/custom/.git") vim.notify "successfully installed chadrc template!" + vim.cmd "redraw|echo ''" end end end @@ -35,7 +38,6 @@ end vim.api.nvim_create_autocmd("User", { pattern = "PackerComplete", callback = function() - M.install_template() require("base46").load_all_highlights() vim.cmd "bw | silent! MasonInstallAll" -- close packer window