add windows support for compile theme autocmd

This commit is contained in:
siduck 2023-02-15 17:37:10 +05:30
parent e8e7ed6144
commit 5246faa09a
2 changed files with 32 additions and 9 deletions

View file

@ -25,7 +25,7 @@ M.lazy = function(install_path)
require "plugins" require "plugins"
vim.fn.mkdir(vim.g.base46_cache, "p") vim.fn.mkdir(vim.g.base46_cache, "p")
vim.cmd "CompileNvTheme" require("base46").load_all_highlights()
require("lazy").load { plugins = "nvim-treesitter" } require("lazy").load { plugins = "nvim-treesitter" }
-- install binaries from mason.nvim & tsparsers on LazySync -- install binaries from mason.nvim & tsparsers on LazySync

View file

@ -19,14 +19,37 @@ autocmd("FileType", {
end, end,
}) })
autocmd("BufWritePost", { local sep = vim.loop.os_uname().sysname:find "windows" and "\\" or "/"
pattern = "*lua",
callback = function()
local bufname = vim.api.nvim_buf_get_name(0)
if string.find(bufname, "custom") and string.find(bufname, "lua") then vim.api.nvim_create_autocmd("BufWritePost", {
pattern = vim.fn.glob(
table.concat({
vim.fn.stdpath "config",
"lua",
"custom",
"**",
"*.lua",
}, sep),
true,
true,
true
),
group = vim.api.nvim_create_augroup("ReloadNvChad", {}),
callback = function(opts)
require("plenary.reload").reload_module "base46" require("plenary.reload").reload_module "base46"
local file = string
.gsub(vim.fn.fnamemodify(opts.file, ":r"), vim.fn.stdpath "config" .. sep .. "lua" .. sep, "")
:gsub(sep, ".")
require("plenary.reload").reload_module(file)
require("plenary.reload").reload_module "custom.chadrc"
local config = require("core.utils").load_config().ui
vim.opt.statusline = "%!v:lua.require('nvchad_ui.statusline." .. config.statusline.theme .. "').run()"
require("base46").load_all_highlights() require("base46").load_all_highlights()
end -- vim.cmd("redraw!")
end, end,
}) })