Skip to content

Commit

Permalink
Add documentation for cond setting
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick96 authored and theHamsta committed Nov 27, 2021
1 parent 5031475 commit be1c93f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion doc/nvim-treesitter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,23 @@ Each module corresponds to an entry in the dictionary passed to the
EOF
<

All modules share some common options, like `enable` and `disable`.
All modules share some common options, like `enable`, `disable`, and `cond`.
When `enable` is `true` this will enable the module for all supported languages,
if you want to disable the module for some languages you can pass a list to the `disable` option.
For more fine-grained control, `cond` takes a function and whenever it returns
`false` the module is disabled for that buffer.
The `cond` function is called once when a module starts in a buffer and
received the language and the buffer number as arguments.

>
lua <<EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
disable = { "cpp", "lua" },
cond = function(lang, bufnr) -- Disable in large C++ buffers
return not (lang == "cpp" and api.nvim_buf_line_count(bufnr) > 50000)
end,
},
}
EOF
Expand Down

0 comments on commit be1c93f

Please sign in to comment.