From cbd3703c6bd6b5930c32e06a51573374a7a615b5 Mon Sep 17 00:00:00 2001 From: jyn Date: Fri, 11 Apr 2025 07:06:31 -0400 Subject: [PATCH] Document `textobjects` support This is really just a quick draft; I figure it's better to have something short and a link to the full reference than nothing at all. --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9447e0f65..461d86076 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ To make sure a parser is at the latest compatible version (as specified in `nvim ## Modules -Each module provides a distinct tree-sitter-based feature such as [highlighting](#highlight), [indentation](#indentation), or [folding](#folding); see [`:h nvim-treesitter-modules`](doc/nvim-treesitter.txt) or ["Available modules"](#available-modules) below for a list of modules and their options. +Each module provides a distinct tree-sitter-based feature such as [highlighting](#highlight), [indentation](#indentation), [textobjects](#text-objects), or [folding](#folding); see [`:h nvim-treesitter-modules`](doc/nvim-treesitter.txt) or ["Available modules"](#available-modules) below for a list of modules and their options. Following examples assume that you are configuring neovim with lua. If you are using vimscript, see `:h lua-heredoc`. All modules are disabled by default and need to be activated explicitly in your `init.lua`, e.g., via @@ -566,6 +566,27 @@ require'nvim-treesitter.configs'.setup { } ``` +#### Text objects + +Neovim `:text-objects` integration. This is provided by . + +```lua +require'nvim-treesitter.configs'.setup { + textobjects = { + select = { + enable = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + } + } + } +} +``` + +See for a complete list of possible textobjects. + + #### Folding Tree-sitter based folding (implemented in Neovim itself, see `:h vim.treesitter.foldexpr()`). To enable it for the current window, set