diff --git a/nvim/init.lua b/nvim/init.lua index 9e08b84..58415bf 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -18,7 +18,14 @@ require("nvim-treesitter.configs").setup({ ensure_installed = "all", highlight = { enable = true, -- false will disable the whole extension - disable = {}, -- list of language that will be disabled + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + disable = function(lang, 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, }, })