update large file detection

This commit is contained in:
xfy
2024-12-06 16:42:39 +08:00
parent d42adee2dd
commit 633136394e
2 changed files with 26 additions and 13 deletions

View File

@ -1,12 +1,3 @@
-- Detect large files and disable syntax highlighting for them
local file_larger_than_100_kb = function(buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end
return {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
@ -48,11 +39,11 @@ return {
},
auto_install = true,
highlight = {
enable = function(_, buf)
return not file_larger_than_100_kb(buf)
enable = function()
return not vim.b.large_buf
end,
disable = function(_, buf)
return file_larger_than_100_kb(buf)
disable = function()
return vim.b.large_buf
end,
},
},