Skip to content

Commit

Permalink
fix(sync): [regression] load rocks.nvim modules before trying to use …
Browse files Browse the repository at this point in the history
…them
  • Loading branch information
mrcjkb committed Dec 18, 2024
1 parent d760a7f commit c1eebd4
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions lua/rocks/operations/sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,28 @@ operations.sync = function(user_rocks, on_complete)
callback(report_progress, report_error, helpers.manage_rock_stub)
end

adapter.synchronise_site_symlinks()

vim
.iter(sync_status.to_install)
---@param rock_name string
:map(function(rock_name)
return user_rocks[rock_name]
end)
---@param rock_spec RockSpec
:filter(function(rock_spec)
return not vim
.iter(skipped_rocks)
---@param skipped_rock SyncSkippedRock
:any(function(skipped_rock)
return skipped_rock.spec.name == rock_spec.name
and skipped_rock.spec.version == rock_spec.version
end)
end)
:each(function(rock_spec)
helpers.dynamic_load(rock_spec).wait()
end)

-- rocks.nvim sync handlers should be installed now.
-- try installing any rocks that rocks.nvim could not handle itself
for _, skipped_rock in ipairs(skipped_rocks) do
Expand All @@ -146,6 +168,7 @@ operations.sync = function(user_rocks, on_complete)
local callback = handlers.get_sync_handler_callback(spec)
if callback then
callback(report_progress, report_error, helpers.manage_rock_stub)
helpers.dynamic_load(spec).wait()
else
report_error(("Failed to install %s: %s"):format(spec.name, skipped_rock.reason))
end
Expand Down Expand Up @@ -250,18 +273,6 @@ operations.sync = function(user_rocks, on_complete)
refresh_rocks_state()
until vim.tbl_isempty(prunable_rocks)

adapter.synchronise_site_symlinks()

vim
.iter(sync_status.to_install)
---@param rock_name string
:map(function(rock_name)
return user_rocks[rock_name]
end)
:each(function(rock_spec)
helpers.dynamic_load(rock_spec).wait()
end)

helpers.postInstall()
if not vim.tbl_isempty(error_handles) then
local message = "Sync completed with errors! Run ':Rocks log' for details."
Expand Down

0 comments on commit c1eebd4

Please sign in to comment.