Files
dotfiles/nvim/lua/autocmds.lua
FaultyBranches 36c3852bc3 refactor: Moving the wezterm local file linux cursor fix into the main
config file, fixing treesitter folding (maybe) and removing the old
attempt at a fix, slight fixes to formatting in other files.
2026-03-31 15:56:08 -05:00

23 lines
874 B
Lua

-- Disables syntax, treesitter and folding on larger files
vim.api.nvim_create_autocmd({ 'BufReadPre' }, {
pattern = '*',
group = vim.api.nvim_create_augroup('largefile', { clear = true }),
callback = function(args)
local max_filesize_MiB = 2
local _, stats = pcall(function()
return vim.loop.fs_stat(vim.api.nvim_buf_get_name(args.buf))
end)
local file_size = math.floor(0.5 + (stats.size / (1024 * 1024)))
if file_size > max_filesize_MiB then
print(string.format('File detected above %sMiB. Disabling syntax, treesitter, and folding.', max_filesize_MiB))
vim.api.nvim_command('set foldmethod=manual')
vim.api.nvim_command('set noswapfile')
vim.api.nvim_command('set noundofile')
vim.api.nvim_command('set noloadplugins')
end
end,
})