bootstrap base46 before lazy

fix https://github.com/NvChad/base46/issues/166
This commit is contained in:
siduck 2023-03-26 15:52:41 +05:30
parent ed03799697
commit 609000db5b
3 changed files with 21 additions and 13 deletions

View File

@ -8,11 +8,11 @@ end
require("core.utils").load_mappings() require("core.utils").load_mappings()
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
-- bootstrap lazy.nvim! -- bootstrap lazy.nvim!
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
require("core.bootstrap").base46()
require("core.bootstrap").gen_chadrc_template() require("core.bootstrap").gen_chadrc_template()
require("core.bootstrap").lazy(lazypath) require("core.bootstrap").lazy(lazypath)
end end

View File

@ -1,7 +1,20 @@
local M = {} 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) 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" local repo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system { "git", "clone", "--filter=blob:none", "--branch=stable", repo, install_path } 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 if packages:match "%S" == nil then
vim.schedule(function() vim.schedule(function()
vim.api.nvim_buf_delete(0, { force = true }) 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 end
end) end)
@ -33,28 +46,23 @@ end
M.gen_chadrc_template = function() M.gen_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
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 repo = "https://github.com/NvChad/example_config"
local install_path = vim.fn.stdpath "config" .. "/lua/custom" local install_path = vim.fn.stdpath "config" .. "/lua/custom"
vim.fn.system { "git", "clone", "--depth", "1", repo, install_path } vim.fn.system { "git", "clone", "--depth", "1", repo, install_path }
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.fn.delete(vim.fn.stdpath "config" .. "/lua/custom/.git", "rf")
vim.notify "successfully installed chadrc template!" vim.cmd "redraw|echo '' | echo 'successfully installed chadrc template!'"
vim.cmd "redraw|echo ''"
else else
local custom_dir = vim.fn.stdpath "config" .. "/lua/custom/" local custom_dir = vim.fn.stdpath "config" .. "/lua/custom/"
vim.fn.mkdir(custom_dir, "p") vim.fn.mkdir(custom_dir, "p")
local file = io.open(custom_dir .. "chadrc.lua", "w") local file = io.open(custom_dir .. "chadrc.lua", "w")
file:write "local M = {} \n M.ui = { theme = 'onedark' } \n return M" file:write("local M = {}\n M.ui = {theme = 'onedark'}\n return M"):close()
file:close()
end end
end end
end end

View File

@ -81,7 +81,7 @@ local default_plugins = {
return require "plugins.configs.treesitter" return require "plugins.configs.treesitter"
end, end,
config = function(_, opts) config = function(_, opts)
pcall(dofile, vim.g.base46_cache .. "syntax") dofile(vim.g.base46_cache .. "syntax")
require("nvim-treesitter.configs").setup(opts) require("nvim-treesitter.configs").setup(opts)
end, end,
}, },