aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/node_spec.lua
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2024-07-28 13:30:33 -0700
committerChristian Clason <c.clason@uni-graz.at>2024-07-29 17:15:46 +0200
commit1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654 (patch)
treecd48dc0520895b0e63af1b3f36706f406344d9bd /test/functional/treesitter/node_spec.lua
parentbd3b6ec8360e0dd6edfe74c3d0013fd2b98b989e (diff)
downloadrneovim-1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654.tar.gz
rneovim-1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654.tar.bz2
rneovim-1af55bfcf21b9bc7594b9c5ee0c2f60cbb887654.zip
feat(treesitter): allow get_node to return anonymous nodes
Adds a new field `include_anonymous` to the `get_node` options to allow anonymous nodes to be returned.
Diffstat (limited to 'test/functional/treesitter/node_spec.lua')
-rw-r--r--test/functional/treesitter/node_spec.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua
index 96579f296b..6270ea3aa1 100644
--- a/test/functional/treesitter/node_spec.lua
+++ b/test/functional/treesitter/node_spec.lua
@@ -55,6 +55,23 @@ describe('treesitter node API', function()
eq('identifier', lua_eval('node:type()'))
end)
+ it('get_node() with anonymous nodes included', function()
+ insert([[print('test')]])
+
+ exec_lua([[
+ parser = vim.treesitter.get_parser(0, 'lua')
+ tree = parser:parse()[1]
+ node = vim.treesitter.get_node({
+ bufnr = 0,
+ pos = { 0, 6 }, -- on the first apostrophe
+ include_anonymous = true,
+ })
+ ]])
+
+ eq("'", lua_eval('node:type()'))
+ eq(false, lua_eval('node:named()'))
+ end)
+
it('can move between siblings', function()
insert([[
int main(int x, int y, int z) {