From 035d9f525a987dee7e7d6ac69ea8b25bb5cdcec9 Mon Sep 17 00:00:00 2001 From: Benjamin Schmidt Date: Fri, 27 Oct 2023 21:01:34 +0200 Subject: [PATCH] fix(meta): fix treesitter integration (#1104) Treesitters `for_each_child()` will be deprecated in 0.11. It ias encouraged to use `children()` and implement the recursion yourself. We use a loop to iterate over the tree's children and call the usual function for each child. fixes #1104 --- lua/neorg/modules/core/esupports/metagen/module.lua | 6 +++--- lua/neorg/modules/core/integrations/treesitter/module.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/neorg/modules/core/esupports/metagen/module.lua b/lua/neorg/modules/core/esupports/metagen/module.lua index 9165f67be..c3d8a46b4 100644 --- a/lua/neorg/modules/core/esupports/metagen/module.lua +++ b/lua/neorg/modules/core/esupports/metagen/module.lua @@ -245,7 +245,7 @@ module.public = { local meta_root = nil - languagetree:for_each_child(function(tree) + for _, tree in pairs(languagetree:children()) do if tree:lang() ~= "norg_meta" or meta_root then return end @@ -257,7 +257,7 @@ module.public = { end meta_root = meta_tree:root() - end) + end if not meta_root then return @@ -375,4 +375,4 @@ module.events.subscribed = { }, } -return module +return module \ No newline at end of file diff --git a/lua/neorg/modules/core/integrations/treesitter/module.lua b/lua/neorg/modules/core/integrations/treesitter/module.lua index e87361719..1d90a9946 100644 --- a/lua/neorg/modules/core/integrations/treesitter/module.lua +++ b/lua/neorg/modules/core/integrations/treesitter/module.lua @@ -576,7 +576,7 @@ module.public = { local result = {} - languagetree:for_each_child(function(tree) + for _, tree in ipairs(languagetree:children()) do if tree:lang() ~= "norg_meta" then return end @@ -661,7 +661,7 @@ module.public = { ) end end - end) + end return result end, @@ -768,4 +768,4 @@ module.events.subscribed = { }, } -return module +return module \ No newline at end of file