aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorpatrick96 <p.ziegler96@gmail.com>2021-11-20 22:31:22 +0100
committerStephan Seitz <stephan.seitz@fau.de>2021-11-28 00:31:02 +0100
commitd24a1c63d4057e858d47e4594c8899cbf1536121 (patch)
treec502a5ccf4c02e03540b17d94c69e0e89cb48a06 /doc
parentRename cond to condition (diff)
downloadnvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar
nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.gz
nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.bz2
nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.lz
nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.xz
nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.zst
nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.zip
Make disable accept a function
Replaces the condition setting (though it does the exact inverse)
Diffstat (limited to 'doc')
-rw-r--r--doc/nvim-treesitter.txt25
1 files changed, 19 insertions, 6 deletions
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt
index 9cc975ed2..d0f204146 100644
--- a/doc/nvim-treesitter.txt
+++ b/doc/nvim-treesitter.txt
@@ -74,14 +74,9 @@ Each module corresponds to an entry in the dictionary passed to the
EOF
<
-All modules share some common options, like `enable`, `disable`, and
-`condition`.
+All modules share some common options, like `enable` and `disable`.
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, `condition` takes a function and whenever it returns
-`false` the module is disabled for that buffer.
-The `condition` function is called once when a module starts in a buffer and
-received the language and the buffer number as arguments.
>
lua <<EOF
@@ -97,6 +92,24 @@ received the language and the buffer number as arguments.
EOF
<
+For more fine-grained control, `disabled` can also take a function and
+whenever it returns `true`, the module is disabled for that buffer.
+The function is called once when a module starts in a buffer and receives the
+language and buffer number as arguments:
+
+>
+ lua <<EOF
+ require'nvim-treesitter.configs'.setup {
+ highlight = {
+ enable = true,
+ disable = function(lang, bufnr) -- Disable in large C++ buffers
+ return lang == "cpp" and api.nvim_buf_line_count(bufnr) > 50000
+ end,
+ },
+ }
+ EOF
+<
+
Options that define or accept a keymap use the same format you use to define
keymaps in Neovim, so you can write keymaps as `gd`, `<space>a`, `<leader>a`
`<C-a>` (control + a), `<A-n>` (alt + n), `<CR>` (enter), etc.