From e2efbb6569dbe50e6604cfc2d5d0819eb07d5623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Boczar?= Date: Sat, 1 Oct 2022 22:30:01 +0200 Subject: [PATCH] docs: add example of how to use function to disable a module --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 3f75be28d..9a1ca98a4 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,14 @@ require'nvim-treesitter.configs'.setup { -- the name of the parser) -- list of language that will be disabled disable = { "c", "rust" }, + -- 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, -- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).