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, }) vim.api.nvim_create_autocmd("FileType", { pattern = "*", callback = function() pcall(vim.treesitter.start) end, }) local create_cmd = vim.api.nvim_create_user_command create_cmd("TSInstallAll", function() local spec = require("lazy.core.config").plugins["nvim-treesitter"] local opts = type(spec.opts) == "table" and spec.opts or {} require("nvim-treesitter").install(opts.ensure_installed) end, {})