Skip to content

Commit

Permalink
bootstrap base46 before lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
siduck authored and camfrey committed Jun 23, 2023
1 parent 0b89f79 commit eedf80b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 19 additions & 11 deletions lua/core/bootstrap.lua
Original file line number Diff line number Diff line change
@@ -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 }
Expand All @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit eedf80b

Please sign in to comment.