diff options
| author | L Lllvvuu <git@llllvvuu.dev> | 2023-09-27 02:51:42 -0700 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2023-11-04 14:55:44 +0100 |
| commit | 6c150e0b9312ece13f13b7ff2e9743592bc9d431 (patch) | |
| tree | 5c4535c1570cf3520306930f71e6ba2046f74609 /runtime/doc | |
| parent | d3e9cbedc700a5ae9f64fdced07cdddbb4ef13d1 (diff) | |
| download | rneovim-6c150e0b9312ece13f13b7ff2e9743592bc9d431.tar.gz rneovim-6c150e0b9312ece13f13b7ff2e9743592bc9d431.tar.bz2 rneovim-6c150e0b9312ece13f13b7ff2e9743592bc9d431.zip | |
docs(treesitter): add disclaimer about needing to parse before `get_node()`
Problem:
---
Misuse of `get_node()` is common:
https://github.com/search?q=get_node_at_cursor+language%3Alua&type=code
Solution:
---
Add a note clarifying proper usage.
Diffstat (limited to 'runtime/doc')
| -rw-r--r-- | runtime/doc/treesitter.txt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index e19fda8fd1..c65c9c22ba 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -599,6 +599,12 @@ get_captures_at_pos({bufnr}, {row}, {col}) get_node({opts}) *vim.treesitter.get_node()* Returns the smallest named node at the given position + NOTE: Calling this on an unparsed tree can yield an invalid node. If the + tree is not known to be parsed by, e.g., an active highlighter, parse the + tree first via >lua + vim.treesitter.get_parser(bufnr):parse(range) +< + Parameters: ~ • {opts} (table|nil) Optional keyword arguments: • bufnr integer|nil Buffer number (nil or 0 for current |