NvChad/lua/nvchad/autocmds.lua
siduck 8ad6845386 move some autocmds into ui repo
as the filetype one is related to tabufline and the bufwritepost one is used for reloading nvconfig
2024-06-23 18:48:26 +05:30

28 lines
915 B
Lua

local autocmd = vim.api.nvim_create_autocmd
-- user event that loads after UIEnter + only if file buf is there
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_get_option_value("buftype", { buf = args.buf })
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", {})
if vim.g.editorconfig then
require("editorconfig").config(args.buf)
end
end)
end
end,
})