aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-10-30 10:51:41 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2020-11-01 14:59:17 +0100
commit03c478ae53c71d0693f1d72b0da9706569cb8fba (patch)
treea0523d53364e40dc6013acee11600ca06b526703 /src
parent037ffd54dcd8edba6787d93273e6696b7a366ac6 (diff)
downloadrneovim-03c478ae53c71d0693f1d72b0da9706569cb8fba.tar.gz
rneovim-03c478ae53c71d0693f1d72b0da9706569cb8fba.tar.bz2
rneovim-03c478ae53c71d0693f1d72b0da9706569cb8fba.zip
treesitter: add node:id()
Diffstat (limited to 'src')
-rw-r--r--src/nvim/lua/treesitter.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index 5258352e72..2105beee2a 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -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 },
@@ -621,6 +622,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;