2022-05-23 07:24:03 +00:00
|
|
|
local autocmd = vim.api.nvim_create_autocmd
|
|
|
|
|
2022-07-08 13:50:57 +00:00
|
|
|
-- dont list quickfix buffers
|
|
|
|
autocmd("FileType", {
|
2022-07-22 16:00:00 +00:00
|
|
|
pattern = "qf",
|
|
|
|
callback = function()
|
|
|
|
vim.opt_local.buflisted = false
|
|
|
|
end,
|
2022-07-08 13:50:57 +00:00
|
|
|
})
|
2023-02-14 05:42:31 +00:00
|
|
|
|
2023-03-14 08:28:12 +00:00
|
|
|
-- reload some chadrc options on-save
|
2023-07-02 10:52:52 +00:00
|
|
|
autocmd("BufWritePost", {
|
|
|
|
pattern = vim.tbl_map(function(path)
|
|
|
|
return vim.fs.normalize(vim.loop.fs_realpath(path))
|
2024-03-04 06:26:40 +00:00
|
|
|
end, vim.fn.glob(vim.fn.stdpath "config" .. "/lua/**/*.lua", true, true, true)),
|
2023-02-15 12:07:10 +00:00
|
|
|
group = vim.api.nvim_create_augroup("ReloadNvChad", {}),
|
|
|
|
|
2023-03-10 06:10:24 +00:00
|
|
|
callback = function(opts)
|
2023-03-18 05:14:42 +00:00
|
|
|
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("/", ".")
|
2023-03-23 23:05:54 +00:00
|
|
|
|
2023-10-16 01:54:14 +00:00
|
|
|
require("plenary.reload").reload_module "nvconfig"
|
2023-02-15 12:07:10 +00:00
|
|
|
require("plenary.reload").reload_module "base46"
|
2023-03-18 03:40:36 +00:00
|
|
|
require("plenary.reload").reload_module(module)
|
2023-02-15 12:07:10 +00:00
|
|
|
|
2023-10-16 01:54:14 +00:00
|
|
|
local config = require "nvconfig"
|
2023-03-10 06:19:54 +00:00
|
|
|
|
2023-03-14 08:28:12 +00:00
|
|
|
-- statusline
|
2023-10-09 11:43:11 +00:00
|
|
|
if config.ui.statusline.theme ~= "custom" then
|
2024-03-04 02:37:10 +00:00
|
|
|
require("plenary.reload").reload_module("nvchad.stl.utils")
|
|
|
|
require("plenary.reload").reload_module("nvchad.stl." .. config.ui.statusline.theme)
|
|
|
|
vim.opt.statusline = "%!v:lua.require('nvchad.stl." .. config.ui.statusline.theme .. "')()"
|
2023-10-09 11:43:11 +00:00
|
|
|
end
|
2023-02-14 05:42:31 +00:00
|
|
|
|
2023-07-26 01:26:56 +00:00
|
|
|
-- tabufline
|
2023-07-26 04:28:01 +00:00
|
|
|
if config.ui.tabufline.enabled then
|
2023-08-09 14:52:46 +00:00
|
|
|
require("plenary.reload").reload_module "nvchad.tabufline.modules"
|
2024-03-04 02:37:10 +00:00
|
|
|
vim.opt.tabline = "%!v:lua.require('nvchad.tabufline.modules')()"
|
2023-07-26 04:28:01 +00:00
|
|
|
end
|
2023-07-26 01:26:56 +00:00
|
|
|
|
2023-02-15 12:07:10 +00:00
|
|
|
require("base46").load_all_highlights()
|
2023-03-10 06:10:24 +00:00
|
|
|
-- vim.cmd("redraw!")
|
2023-02-14 05:42:31 +00:00
|
|
|
end,
|
|
|
|
})
|
2023-03-09 12:37:58 +00:00
|
|
|
|
2024-01-28 16:03:38 +00:00
|
|
|
-- user event that loads after UIEnter + only if file buf is there
|
|
|
|
vim.api.nvim_create_autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, {
|
|
|
|
group = vim.api.nvim_create_augroup("NvFilePost", { clear = true }),
|
|
|
|
callback = function(args)
|
|
|
|
local file = vim.api.nvim_buf_get_name(args.buf)
|
|
|
|
local buftype = vim.api.nvim_buf_get_option(args.buf, "buftype")
|
|
|
|
|
|
|
|
if not vim.g.ui_entered and args.event == "UIEnter" then
|
|
|
|
vim.g.ui_entered = true
|
|
|
|
end
|
|
|
|
|
|
|
|
if file ~= "" and buftype ~= "nofile" and vim.g.ui_entered then
|
|
|
|
vim.api.nvim_exec_autocmds("User", { pattern = "FilePost", modeline = false })
|
|
|
|
vim.api.nvim_del_augroup_by_name "NvFilePost"
|
|
|
|
|
|
|
|
vim.schedule(function()
|
|
|
|
vim.api.nvim_exec_autocmds("FileType", {})
|
2024-02-17 01:01:11 +00:00
|
|
|
|
|
|
|
if vim.g.editorconfig then
|
|
|
|
require("editorconfig").config(args.buf)
|
|
|
|
end
|
2024-01-28 16:03:38 +00:00
|
|
|
end, 0)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|