mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50:09 -04:00
docs: add example of how to use function to disable a module
This commit is contained in:
parent
aebc6cf6bd
commit
e2efbb6569
1 changed files with 8 additions and 0 deletions
|
|
@ -127,6 +127,14 @@ require'nvim-treesitter.configs'.setup {
|
||||||
-- the name of the parser)
|
-- the name of the parser)
|
||||||
-- list of language that will be disabled
|
-- list of language that will be disabled
|
||||||
disable = { "c", "rust" },
|
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.
|
-- 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).
|
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue