Skip to content

feat: update remote plugins after install/update #485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/rocks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ RocksOpts *RocksOpts*
(Default: `true` for the best default experience).
{generate_help_pages?} (boolean)
Whether to re-generate plugins help pages after installation/upgrade. (Default: `true`).
{update_remote_plugins?} (boolean)
Whether to update remote plugins after installation/upgrade. (Default: `true`).
{reinstall_dev_rocks_on_update?} (boolean)
Whether to reinstall 'dev' rocks on update
(Default: `true`, as rocks.nvim cannot determine if 'dev' rocks are up to date).
Expand Down
3 changes: 3 additions & 0 deletions lua/rocks/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ local config = {}
--- Whether to re-generate plugins help pages after installation/upgrade. (Default: `true`).
---@field generate_help_pages? boolean
---
--- Whether to update remote plugins after installation/upgrade. (Default: `true`).
---@field update_remote_plugins? boolean
---
--- Whether to reinstall 'dev' rocks on update
--- (Default: `true`, as rocks.nvim cannot determine if 'dev' rocks are up to date).
---@field reinstall_dev_rocks_on_update? boolean
Expand Down
2 changes: 2 additions & 0 deletions lua/rocks/config/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ local default_config = {
dynamic_rtp = true,
---@type boolean Whether to re-generate plugins help pages after installation/upgrade
generate_help_pages = true,
---@type boolean Whether to update remote plugins after installation/upgrade
update_remote_plugins = true,
---@type boolean Whether to reinstall 'dev' rocks on update
reinstall_dev_rocks_on_update = true,
---@type boolean Whether to use the luarocks loader to support multiple dependencies
Expand Down
5 changes: 1 addition & 4 deletions lua/rocks/operations/add.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ Use 'Rocks %s {rock_name}' or install rocks-git.nvim.
fs.write_file_await(config.config_path, "w", tostring(user_rocks))
cache.populate_all_rocks_state_caches()
vim.schedule(function()
-- Re-generate help tags
if config.generate_help_pages then
vim.cmd.helptags("ALL")
end
helpers.postInstall()
if success then
progress_handle:finish()
if callback then
Expand Down
11 changes: 11 additions & 0 deletions lua/rocks/operations/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,15 @@ Breaking changes:
)
end, 2)

--- Post-install actions
function helpers.postInstall()
if config.update_remote_plugins and type(vim.cmd.UpdateRemotePlugins) == "function" then
pcall(vim.cmd.UpdateRemotePlugins)
end
-- Re-generate help tags
if config.generate_help_pages then
vim.cmd.helptags("ALL")
end
end

return helpers
5 changes: 1 addition & 4 deletions lua/rocks/operations/sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,7 @@ operations.sync = function(user_rocks, on_complete)
end)
:each(helpers.dynamic_load)

-- Re-generate help tags
if config.generate_help_pages then
vim.cmd.helptags("ALL")
end
helpers.postInstall()
if not vim.tbl_isempty(error_handles) then
local message = "Sync completed with errors! Run ':Rocks log' for details."
log.error(message)
Expand Down
5 changes: 1 addition & 4 deletions lua/rocks/operations/update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ update.update = function(on_complete, opts)
cache.populate_all_rocks_state_caches()
adapter.synchronise_site_symlinks()

-- Re-generate help tags
if config.generate_help_pages then
vim.cmd.helptags("ALL")
end
helpers.postInstall()
if on_complete then
on_complete()
end
Expand Down