-- Files above the limit get vim.b.bigfile = true. Treesitter, LSP, linting and -- AI completion check that flag; syntax and folding are switched off here. local M = {} M.limit = 1024 * 1024 local group = vim.api.nvim_create_augroup("core.bigfile", { clear = true }) vim.api.nvim_create_autocmd("BufReadPre", { group = group, callback = function(ev) local stat = vim.uv.fs_stat(ev.match) if stat and stat.size > M.limit then vim.b[ev.buf].bigfile = true end end, }) vim.api.nvim_create_autocmd("FileType", { group = group, callback = function(ev) if not vim.b[ev.buf].bigfile then return end vim.schedule(function() if vim.api.nvim_buf_is_valid(ev.buf) then vim.bo[ev.buf].syntax = "" vim.api.nvim_buf_call(ev.buf, function() vim.wo.foldmethod = "manual" end) end end) end, }) return M