feat: Adding in a custom statuscolumn formatting function and lua file

This commit is contained in:
2026-07-08 14:05:40 -05:00
parent e623cfdd40
commit 96e93d46ce
3 changed files with 102 additions and 58 deletions

View File

@@ -1,22 +1,43 @@
-- Autocommands for handling large files and switching between large file buffers and others
local largefile_group = vim.api.nvim_create_augroup('largefile', { clear = true })
local max_filesize = 4 * (1024 * 1024) -- 4 MB
local old_eventignore = false
-- 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 = 1
group = largefile_group,
callback = function(ev)
if ev.file then
local status, size = pcall(function() return vim.loop.fs_stat(ev.file).size end)
if status and size > max_filesize then
old_eventignore = vim.o.eventignore
vim.o.eventignore = 'FileType' -- Reduce the calls for filetype specific plugins or syntax highlighting
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')
vim.b[ev.buf].is_large_file = true
vim.bo['bufhidden'] = 'unload'
vim.bo['buftype'] = 'nowrite'
vim.bo['swapfile'] = false
vim.bo['undofile'] = false
vim.bo['undolevels'] = -1
end
end
end,
})
vim.api.nvim_create_autocmd({ 'BufWinEnter' }, {
group = largefile_group,
callback = function(ev)
if old_eventignore ~= false then
vim.o.eventignore = old_eventignore -- Restore the old setting
old_eventignore = false
end
if vim.b[ev.buf].is_large_file then
vim.wo.wrap = false
else
vim.wo.wrap = vim.o.wrap -- Restore to default setting
end
end
})
-- End large file handling