aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-11-01 17:27:38 +0100
committerGitHub <noreply@github.com>2020-11-01 17:27:38 +0100
commit8821587748058ee1ad8523865b30a03582f8d7be (patch)
treed7ad8fcf5e12b3733703c1317bd7249c40435730 /src
parent106a6c9548aa1d90b2761c0b059348f614a27855 (diff)
parent03c478ae53c71d0693f1d72b0da9706569cb8fba (diff)
downloadrneovim-8821587748058ee1ad8523865b30a03582f8d7be.tar.gz
rneovim-8821587748058ee1ad8523865b30a03582f8d7be.tar.bz2
rneovim-8821587748058ee1ad8523865b30a03582f8d7be.zip
Merge pull request #13192 from bfredl/nodeid
] 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 7df8afad62..c53e208b00 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 },
@@ -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;