mirror of
https://github.com/neovim/neovim.git
synced 2026-04-25 08:44:06 +00:00
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.
This commit is contained in:
committed by
Christian Clason
parent
bd3b6ec836
commit
1af55bfcf2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user