Skip to content

Commit

Permalink
Add docs for tree-sitter textobjects
Browse files Browse the repository at this point in the history
  • Loading branch information
sudormrfbin committed Sep 9, 2021
1 parent 6bab0b2 commit 400af6f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions book/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ Multiple characters are currently not supported, but planned.

## Textobjects

Currently supported: `word`, `surround`.
Currently supported: `word`, `surround`, `function`, `class`.

![textobject-demo](https://user-images.githubusercontent.com/23398472/124231131-81a4bb00-db2d-11eb-9d10-8e577ca7b177.gif)
![textobject-treesitter-demo](https://user-images.githubusercontent.com/23398472/132537398-2a2e0a54-582b-44ab-a77f-eb818942203d.gif)

- `ma` - Select around the object (`va` in vim, `<alt-a>` in kakoune)
- `mi` - Select inside the object (`vi` in vim, `<alt-i>` in kakoune)
Expand All @@ -60,5 +61,10 @@ Currently supported: `word`, `surround`.
| --- | --- |
| `w` | Word |
| `(`, `[`, `'`, etc | Specified surround pairs |
| `f` | Function |
| `c` | Class |

Textobjects based on treesitter, like `function`, `class`, etc are planned.
Note: `f`, `c`, etc need a tree-sitter grammar active for the current
document and a special tree-sitter query file to work properly. [Only
some grammars](https://github.com/search?q=repo%3Ahelix-editor%2Fhelix+filename%3Atextobjects.scm&type=Code&ref=advsearch&l=&l=)
currently have the query file implemented. Contributions are welcome !

0 comments on commit 400af6f

Please sign in to comment.