boostrap mason packages properly

print some message when nvchad is totally setup
pull/1866/head
siduck 1 year ago
parent 84bdc2335c
commit 7ec4515179

@ -16,12 +16,29 @@ M.lazy = function(install_path)
-- install plugins + compile their configs
require "plugins"
vim.api.nvim_buf_delete(0, { force = true }) -- close lazy window
vim.defer_fn(function()
vim.cmd "silent! MasonInstallAll"
end, 0)
-- install mason packages
vim.schedule(function()
vim.cmd "Mason"
local packages = {}
for _, pkg_name in ipairs(vim.g.mason_binaries_list) do
packages[pkg_name] = true
vim.cmd("MasonInstall " .. pkg_name)
end
require("mason-registry"):on("package:install:success", function(pkg)
packages[pkg.name] = nil
if vim.tbl_count(packages) == 0 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
end)
end
end)
end)
end
M.gen_chadrc_template = function()
@ -40,7 +57,7 @@ M.gen_chadrc_template = function()
"https://github.com/NvChad/example_config",
vim.fn.stdpath "config" .. "/lua/custom",
}
print "dont forget to read docs from nvchad.com!"
vim.cmd "redraw|echo ''"
-- delete .git from that repo
@ -51,16 +68,8 @@ M.gen_chadrc_template = function()
local custom_dir = vim.fn.stdpath "config" .. "/lua/custom/"
vim.fn.mkdir(custom_dir, "p")
local str = [[
local M = {}
M.ui = {
theme = "onedark",
}
return M
]]
local file = io.open(custom_dir .. "chadrc.lua", "w")
file:write(str)
file:write("local M = {} \n M.ui = { theme = 'onedark' } \n return M")
file:close()
end
end

@ -73,18 +73,17 @@ autocmd("FileType", {
-- reload some chadrc options on-save
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = vim.tbl_map(vim.fs.normalize, vim.fn.glob(
vim.fn.stdpath("config") .. "/lua/custom/**/*.lua",
true,
true,
true
)),
pattern = vim.tbl_map(
vim.fs.normalize,
vim.fn.glob(vim.fn.stdpath "config" .. "/lua/custom/**/*.lua", true, true, true)
),
group = vim.api.nvim_create_augroup("ReloadNvChad", {}),
callback = function(opts)
local fp = vim.fn.fnamemodify(vim.fs.normalize(vim.api.nvim_buf_get_name(opts.buf)), ":r") --[[@as string]]
local app_name = vim.env.NVIM_APPNAME and vim.env.NVIM_APPNAME or "nvim"
local module = string.gsub(fp, "^.*/" .. app_name .. "/lua/", ""):gsub("/", ".")
require("plenary.reload").reload_module "base46"
require("plenary.reload").reload_module(module)
require("plenary.reload").reload_module "custom.chadrc"

@ -1,5 +1,5 @@
local options = {
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
ensure_installed = { "lua-language-server", "stylua" }, -- not an option from mason.nvim
PATH = "skip",

@ -129,6 +129,8 @@ local default_plugins = {
vim.api.nvim_create_user_command("MasonInstallAll", function()
vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
end, {})
vim.g.mason_binaries_list = opts.ensure_installed
end,
},

Loading…
Cancel
Save