From 7d012db9e89b122dc1cad4aecfe35044d752044b Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 26 Mar 2023 13:25:52 -0500 Subject: [PATCH] feat(nvim): disable treesitter on large files (>100KB) --- .../primary/config/lua/plugins/configs/treesitter.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dots/.nvim-environments/primary/config/lua/plugins/configs/treesitter.lua b/dots/.nvim-environments/primary/config/lua/plugins/configs/treesitter.lua index 47e5ff9f..d1b5de09 100755 --- a/dots/.nvim-environments/primary/config/lua/plugins/configs/treesitter.lua +++ b/dots/.nvim-environments/primary/config/lua/plugins/configs/treesitter.lua @@ -6,6 +6,13 @@ nvim_treesitter.setup({ }, highlight = { enable = true, + disable = 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, }, matchup = { enable = true,