Closed HUAHUAI23 closed 9 months ago
The large file cutoff is used repeatedly (not just on BufRead) so allowing a user to supply a handler which could do arbitrarily expensive computations could have significant performance concerns. I'm going to think on this, I can already predict that someone would report a performance issue when in reality it's because they have a slow handler that they themselves wrote.
Most scenarios are Treesitter causing large file jams,i have a thoughts, make a autocmd and through BufReadPre event before file loaded use regex or lsp to illuminate variable, and through BufReadPost event after file loaded use user config to illuminate variable now i use this method to disable some plugs may causing large file jams
-- after file is loaded,determine whether to load indentline and autopair
autocmd("BufReadPost", {
group = myAutoGroupt,
pattern = "*",
callback = function()
local max_filesize = commConf.largefileEdge -- 100 KB
local ok, stats = pcall(loop.fs_stat, api.nvim_buf_get_name(api.nvim_get_current_buf()))
if ok and stats and stats.size < max_filesize then
-- require("plugin-config.todo-comments")
require("indent_blankline.commands").enable()
require("nvim-autopairs").enable()
require("illuminate.engine").toggle()
-- vim.cmd("setlocal spell spelllang=en_us")
end
end,
})
-- disable indentline,autopair,illuminate before loading file, this time the buffer is loaded but file is still not loaded
autocmd("BufReadPre", {
group = myAutoGroupt,
pattern = "*",
callback = function()
-- vim.api.nvim_cmd(vim.api.nvim_parse_cmd("IndentBlanklineDisable", {}), {})
require("indent_blankline.commands").disable()
require("nvim-autopairs").disable()
require("illuminate.engine").toggle()
-- vim.cmd("setlocal nospell")
end,
})
There were a lot of troubles I was experiencing in large files. Going by exclusion it was illuminate that caused the headache.
The performance bottleneck is only when using treesitter as provider. Illuminate is usable without performance issues with other providers in large files. So treesitter could be just commented out as default provider, or a note should be added that it might cause performance issues with large files.
there is a existing options about deal with large file,but it only use line counts of file as its value,can add a hundler like
because some large file is compressed, and it is one line
treesiiter nvim
,