diff options
| author | Jędrzej Boczar <yendreij@gmail.com> | 2022-10-01 22:30:01 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-10-01 22:46:51 -0400 |
| commit | e2efbb6569dbe50e6604cfc2d5d0819eb07d5623 (patch) | |
| tree | a186461eedde882b1df3438a0f39b4a27cf9d340 | |
| parent | aebc6cf6bd4675ac86629f516d612ad5288f7868 (diff) | |
docs: add example of how to use function to disable a module
| -rw-r--r-- | README.md | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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). |
