mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 23:18:33 +00:00
Merge pull request #13192 from bfredl/nodeid
] treesitter: add node:id()
This commit is contained in:
@@ -58,6 +58,7 @@ static struct luaL_Reg node_meta[] = {
|
||||
{ "__tostring", node_tostring },
|
||||
{ "__eq", node_eq },
|
||||
{ "__len", node_child_count },
|
||||
{ "id", node_id },
|
||||
{ "range", node_range },
|
||||
{ "start", node_start },
|
||||
{ "end_", node_end },
|
||||
@@ -633,6 +634,17 @@ static int node_eq(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int node_id(lua_State *L)
|
||||
{
|
||||
TSNode node;
|
||||
if (!node_check(L, 1, &node)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_pushlstring(L, (const char *)&node.id, sizeof node.id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int node_range(lua_State *L)
|
||||
{
|
||||
TSNode node;
|
||||
|
Reference in New Issue
Block a user