summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/treesitter/node_spec.lua
AgeCommit message (Collapse)AuthorFiles
2025-09-24test: remove a few more redundant clear() calls (#35903)zeertzjq1
2025-07-02test(treesitter): test tree:root() is idempotentRodrigodd1
Test for regression #34605
2025-06-06test(treesitter): test node access after tree editRodrigodd1
2025-02-26feat(lua): vim.text.indent()Justin M. Keyes1
Problem: Indenting text is a common task in plugins/scripts for presentation/formatting, yet vim has no way of doing it (especially "dedent", and especially non-buffer text). Solution: Introduce `vim.text.indent()`. It sets the *exact* indentation because that's a more difficult (and thus more useful) task than merely "increasing the current indent" (which is somewhat easy with a `gsub()` one-liner).
2025-02-21fix(treesitter): `TSNode:field()` returns all children with the given fieldRiley Bruins1
2025-01-27build(deps)!: bump tree-sitter to HEAD, wasmtime to v29.0.1 (#32200)Christian Clason1
Breaking change: `ts_node_child_containing_descendant()` was removed Breaking change: tree-sitter 0.25 (HEAD) required
2025-01-12feat(treesitter)!: don't parse tree in get_parser() or start()Riley Bruins1
**Problem:** `vim.treesitter.get_parser()` and `vim.treesitter.start()` both parse the tree before returning it. This is problematic because if this is a sync parse, it will stall the editor on large files. If it is an async parse, the functions return stale trees. **Solution:** Remove this parsing side effect and leave it to the user to parse the returned trees, either synchronously or asynchronously.
2024-10-11feat(treesitter): introduce child_with_descendant()Riley Bruins1
This commit also marks `child_containing_descendant()` as deprecated (per upstream's documentation), and uses `child_with_descendant()` in its place. Minimum required tree-sitter version will now be `0.24`.
2024-09-21test: support upvalues in exec_luaLewis Russell1
2024-08-02test: allow exec_lua to handle functionsLewis Russell1
Problem: Tests have lots of exec_lua calls which input blocks of code provided as unformatted strings. Solution: Teach exec_lua how to handle functions.
2024-07-29feat(treesitter): allow get_node to return anonymous nodesRiley Bruins1
Adds a new field `include_anonymous` to the `get_node` options to allow anonymous nodes to be returned.
2024-05-16perf(treesitter): use child_containing_descendant() in has-ancestor? (#28512)vanaigr1
Problem: `has-ancestor?` is O(n²) for the depth of the tree since it iterates over each of the node's ancestors (bottom-up), and each ancestor takes O(n) time. This happens because tree-sitter's nodes don't store their parent nodes, and the tree is searched (top-down) each time a new parent is requested. Solution: Make use of new `ts_node_child_containing_descendant()` in tree-sitter v0.22.6 (which is now the minimum required version) to rewrite the `has-ancestor?` predicate in C to become O(n). For a sample file, decreases the time taken by `has-ancestor?` from 360ms to 6ms.
2024-04-23test: improve test conventionsdundargoc1
Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
2024-04-10refactor(test): inject after_each differentlyLewis Russell1
2024-04-08test: improve test conventionsdundargoc1
Work on https://github.com/neovim/neovim/issues/27004.
2024-03-09feat!: remove deprecated functionsdundargoc1
2024-01-03refactor: format test/*Justin M. Keyes1
2023-12-04fix(treesitter): allow passing lang to vim.treesitter.get_node() now ↵Jongwook Choi1
correctly takes opts.lang (#26360) PROBLEM: `vim.treesitter.get_node()` does not recognize the `lang` in the option table. This option was used in somewhere else, for instance, `vim.treesitter.dev` (for `inspect_tree`) but was never implemented. SOLUTION: Make `get_node()` correctly use `opts.lang` when getting a treesitter parser.
2023-08-29fix(treesitter): fix another TSNode:tree() double freebfredl1
Unfortunately the gc=false objects can refer to a dangling tree if the gc=true tree was freed first. This reuses the same tree object as the node itself is keeping alive via the uservalue of the node userdata. (wrapped in a table due to lua 5.1 restrictions)
2023-08-29fix(treesitter): fix TSNode:tree() double free (#24796)nwounkn1
Problem: `push_tree`, every time its called for the same TSTree with `do_copy=false` argument, creates a new userdata for it. Each userdata, when garbage collected, frees the same TSTree C object. Solution: Add flag to userdata, which indicates, should C object, which userdata points to, be freed, when userdata is garbage collected.
2023-03-24feat(treesitter)!: deprecate top level indexes to modules (#22761)Lewis Russell1
The following top level Treesitter functions have been moved: - vim.treesitter.inspect_language() -> vim.treesitter.language.inspect() - vim.treesitter.get_query_files() -> vim.treesitter.query.get_files() - vim.treesitter.set_query() -> vim.treesitter.query.set() - vim.treesitter.query.set_query() -> vim.treesitter.query.set() - vim.treesitter.get_query() -> vim.treesitter.query.get() - vim.treesitter.query.get_query() -> vim.treesitter.query.get() - vim.treesitter.parse_query() -> vim.treesitter.query.parse() - vim.treesitter.query.parse_query() -> vim.treesitter.query.parse() - vim.treesitter.add_predicate() -> vim.treesitter.query.add_predicate() - vim.treesitter.add_directive() -> vim.treesitter.query.add_directive() - vim.treesitter.list_predicates() -> vim.treesitter.query.list_predicates() - vim.treesitter.list_directives() -> vim.treesitter.query.list_directives() - vim.treesitter.query.get_range() -> vim.treesitter.get_range() - vim.treesitter.query.get_node_text() -> vim.treesitter.get_node_text()
2022-09-06ci(tests): don't skip parsers on functionaltestChristian Clason1
Treesitter parsers are now a mandatory part of the installation and should be tested on all platforms. Remove `pending_c_parser` helper.
2022-08-25feat(treesitter): upstream node_length() as a node methodQuentin Rasmont1
Util from the nvim-treesitter project.
2022-08-25feat(treesitter): upstream get_root_for_node() as a node methodQuentin Rasmont1
Util from the nvim-treesitter project.
2022-08-25feat(treesitter): upstream get_named_children() as a node methodQuentin Rasmont1
Util from the nvim-treesitter project.
2021-08-20feat(treesitter): add next, prev sibling methodDylan Kendal1
Add tsnode methods to change to the next, previous, named or unnamed nodes.