From 609000db5b03aa26d2c1d69dc726b9879539200d Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 26 Mar 2023 15:52:41 +0530 Subject: [PATCH] bootstrap base46 before lazy fix https://github.com/NvChad/base46/issues/166 --- init.lua | 2 +- lua/core/bootstrap.lua | 30 +++++++++++++++++++----------- lua/plugins/init.lua | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/init.lua b/init.lua index 9d84f6e..2de4ae5 100644 --- a/init.lua +++ b/init.lua @@ -8,11 +8,11 @@ end require("core.utils").load_mappings() - local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" -- bootstrap lazy.nvim! if not vim.loop.fs_stat(lazypath) then + require("core.bootstrap").base46() require("core.bootstrap").gen_chadrc_template() require("core.bootstrap").lazy(lazypath) end diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index a4488e6..787feab 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -1,7 +1,20 @@ local M = {} +M.base46 = function() + vim.notify " Compiling base46 theme to bytecode ..." + + local repo = "https://github.com/NvChad/base46" + local tmp_path = vim.fn.stdpath "config" .. "/tmp_base46" + + vim.fn.system { "git", "clone", "--depth", "1", "-b", "v2.0", repo, tmp_path } + vim.opt.rtp:prepend(tmp_path) + require("base46").compile() + + vim.fn.delete(tmp_path, "rf") +end + M.lazy = function(install_path) - print "Bootstrapping lazy.nvim .." + vim.cmd "redraw|echo '' | echo ' Installing lazy.nvim & plugins ..'" local repo = "https://github.com/folke/lazy.nvim.git" vim.fn.system { "git", "clone", "--filter=blob:none", "--branch=stable", repo, install_path } @@ -23,7 +36,7 @@ M.lazy = function(install_path) if packages:match "%S" == nil then vim.schedule(function() vim.api.nvim_buf_delete(0, { force = true }) - vim.notify "Now please read the docs at nvchad.com!" -- WIP, show a nice screen after it + vim.api.nvim_echo({ { "Now please read the docs at nvchad.com!! 󰕹 󰱬 ", "NvimInternalError" } }, true, {}) end) end end) @@ -33,28 +46,23 @@ end M.gen_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 - print "cloning chadrc starter template repo...." + vim.cmd "redraw|echo '' | echo 'cloning chadrc starter template repo..'" local repo = "https://github.com/NvChad/example_config" local install_path = vim.fn.stdpath "config" .. "/lua/custom" vim.fn.system { "git", "clone", "--depth", "1", repo, install_path } - 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 ''" + vim.fn.delete(vim.fn.stdpath "config" .. "/lua/custom/.git", "rf") + vim.cmd "redraw|echo '' | echo 'successfully installed chadrc template!'" else local custom_dir = vim.fn.stdpath "config" .. "/lua/custom/" vim.fn.mkdir(custom_dir, "p") local file = io.open(custom_dir .. "chadrc.lua", "w") - file:write "local M = {} \n M.ui = { theme = 'onedark' } \n return M" - file:close() + file:write("local M = {}\n M.ui = {theme = 'onedark'}\n return M"):close() end end end diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 60b528f..9bd34e8 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -81,7 +81,7 @@ local default_plugins = { return require "plugins.configs.treesitter" end, config = function(_, opts) - pcall(dofile, vim.g.base46_cache .. "syntax") + dofile(vim.g.base46_cache .. "syntax") require("nvim-treesitter.configs").setup(opts) end, },