mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-16 01:01:34 +00:00
improve treesitter performance
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
-- 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 {
|
return {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
@ -39,13 +48,11 @@ return {
|
|||||||
},
|
},
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = function(_, buf)
|
||||||
|
return not file_larger_than_100_kb(buf)
|
||||||
|
end,
|
||||||
disable = function(_, buf)
|
disable = function(_, buf)
|
||||||
local max_filesize = 100 * 1024 -- 100 KB
|
return file_larger_than_100_kb(buf)
|
||||||
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,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user