diff --git a/lua/rocks/operations.lua b/lua/rocks/operations.lua index 4f1ca7ed..813e8407 100644 --- a/lua/rocks/operations.lua +++ b/lua/rocks/operations.lua @@ -294,16 +294,14 @@ operations.sync = function(user_rocks) -- Determine dependencies of installed user rocks, so they can be excluded from rocks to prune -- NOTE(mrcjkb): This has to be done after installation, -- so that we don't prune dependencies of newly installed rocks. + -- TODO: This doesn't guarantee that all rocks that can be pruned will be pruned. + -- Typically, another sync will fix this. Maybe we should do some sort of repeat... until? installed_rocks = state.installed_rocks() local dependencies = vim.empty_dict() ---@cast dependencies {[string]: RockDependency} - for _, key in ipairs(key_list) do - if user_rocks[key] and installed_rocks[key] then - -- NOTE(vhyrro): It is not possible to use the vim.tbl_extend or vim.tbl_deep_extend - -- functions here within the async context. It simply refuses to work. - for k, v in pairs(state.rock_dependencies(installed_rocks[key])) do - dependencies[k] = v - end + for _, installed_rock in pairs(installed_rocks) do + for k, v in pairs(state.rock_dependencies(installed_rock)) do + dependencies[k] = v end end diff --git a/lua/rocks/state.lua b/lua/rocks/state.lua index 59bb221e..0af61222 100644 --- a/lua/rocks/state.lua +++ b/lua/rocks/state.lua @@ -96,7 +96,6 @@ state.rock_dependencies = nio.create(function(rock) luarocks.cli({ "show", - "--deps", "--porcelain", rock_name, }, function(obj) @@ -114,7 +113,7 @@ state.rock_dependencies = nio.create(function(rock) end for line in string.gmatch(result, "%S*[^\n]+") do - local name, version = line:match("(%S+)%s%S+%s(%S+)") + local name, version = line:match("dependency%s+(%S+).*using%s+([^-%s]+)") if not name then name = line:match("(%S+)") end @@ -136,7 +135,7 @@ state.query_removable_rocks = nio.create(function() ---@cast dependent_rocks string[] for _, rock in pairs(installed_rocks) do for _, dep in pairs(state.rock_dependencies(rock)) do - dependent_rocks[#dependent_rocks + 1] = dep.name + table.insert(dependent_rocks, dep.name) end end ---@diagnostic disable-next-line: invisible