Some Neovim plugins and features can make Neovim slow when editing big files and executing macros. Faster.nvim will selectively disable some features when big file is opened or macro is executed.
66
stars
0
forks
source link
Enhancement: feature for js files with long lines #2
It would be nice if there was builtin support for detecting files that aren't that big but have really long lines (looking at you minified js files). I currently use this as my config:
return {
'pteroctopus/faster.nvim',
event = { 'BufReadPre', 'BufReadPost' },
opts = function()
vim.api.nvim_create_autocmd('BufReadPost', {
pattern = '*.js',
group = vim.api.nvim_create_augroup('faster_bigfile_custom', {}),
callback = function(args)
local line_count = vim.api.nvim_buf_line_count(args.buf)
---@diagnostic disable-next-line: undefined-field
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(args.buf))
-- if file is at least 10k and the average bytes per line is > 250, then disable everything
if ok and stats and (stats.size > (10 * 1024)) and (stats.size / line_count) > 250 then
vim.notify(
'Disabling for long js file, bytes: ' .. stats.size .. ', lines: ' .. line_count .. ', bytes / lines: ' .. math.floor(stats.size / line_count)
)
vim.cmd('FasterDisableAllFeatures')
vim.b[args.buf].trouble_lualine = false
end
end,
desc = '[faster.nvim] Performance rule for handling js file with long lines',
})
return {}
end,
}
Would be great if there were a builtin feature for that.
Thanks for the suggestion. I'll look into it at some point when I have time. Will probably make it an optional behavior that you can turn on if you want.
First, nice plugin!
It would be nice if there was builtin support for detecting files that aren't that big but have really long lines (looking at you minified js files). I currently use this as my config:
Would be great if there were a builtin feature for that.