lua: add regex support, and @match support in treesitter queries

This commit is contained in:
Björn Linse
2019-11-04 20:40:30 +01:00
parent 08af82b9cb
commit 9c00fea585
6 changed files with 252 additions and 17 deletions

View File

@@ -93,10 +93,7 @@ static PMap(cstr_t) *langs;
static void build_meta(lua_State *L, const char *tname, const luaL_Reg *meta)
{
if (luaL_newmetatable(L, tname)) { // [meta]
for (size_t i = 0; meta[i].name != NULL; i++) {
lua_pushcfunction(L, meta[i].func); // [meta, func]
lua_setfield(L, -2, meta[i].name); // [meta]
}
luaL_register(L, NULL, meta);
lua_pushvalue(L, -1); // [meta, meta]
lua_setfield(L, -2, "__index"); // [meta]