docs: add example of how to use function to disable a module

This commit is contained in:
Jędrzej Boczar 2022-10-01 22:30:01 +02:00 committed by Stephan Seitz
parent aebc6cf6bd
commit e2efbb6569

View file

@ -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).