summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJędrzej Boczar <yendreij@gmail.com>2022-10-01 22:30:01 +0200
committerStephan Seitz <stephan.seitz@fau.de>2022-10-01 22:46:51 -0400
commite2efbb6569dbe50e6604cfc2d5d0819eb07d5623 (patch)
treea186461eedde882b1df3438a0f39b4a27cf9d340
parentaebc6cf6bd4675ac86629f516d612ad5288f7868 (diff)
docs: add example of how to use function to disable a module
-rw-r--r--README.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3f75be28..9a1ca98a 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).