aboutsummaryrefslogtreecommitdiff
path: root/plugins/plugin_manager
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugin_manager')
-rw-r--r--plugins/plugin_manager/init.lua11
-rw-r--r--plugins/plugin_manager/plugin_view.lua23
2 files changed, 29 insertions, 5 deletions
diff --git a/plugins/plugin_manager/init.lua b/plugins/plugin_manager/init.lua
index 274776a..9ed1c28 100644
--- a/plugins/plugin_manager/init.lua
+++ b/plugins/plugin_manager/init.lua
@@ -195,9 +195,9 @@ function PluginManager:get_addons()
return prom
end
-local function run_stateful_plugin_command(plugin_manager, cmd, arg, options)
+local function run_stateful_plugin_command(plugin_manager, cmd, args, options)
local promise = Promise.new()
- run({ cmd, arg }, options.progress):done(function(result)
+ run({ cmd, table.unpack(args) }, options.progress):done(function(result)
if (options.restart == nil and config.plugins.plugin_manager.restart_on_change) or options.restart then
command.perform("core:restart")
else
@@ -208,9 +208,10 @@ local function run_stateful_plugin_command(plugin_manager, cmd, arg, options)
end
-function PluginManager:install(addon, options) return run_stateful_plugin_command(self, "install", addon.id .. (addon.version and (":" .. addon.version) or ""), options) end
-function PluginManager:uninstall(addon, options) return run_stateful_plugin_command(self, "uninstall", addon.id, options) end
-function PluginManager:reinstall(addon, options) return run_stateful_plugin_command(self, "reinstall", addon.id, options) end
+function PluginManager:install(addon, options) return run_stateful_plugin_command(self, "install", { addon.id .. (addon.version and (":" .. addon.version) or "") }, options) end
+function PluginManager:reinstall(addon, options) return run_stateful_plugin_command(self, "install", { addon.id .. (addon.version and (":" .. addon.version) or ""), "--reinstall" }, options) end
+function PluginManager:uninstall(addon, options) return run_stateful_plugin_command(self, "uninstall", { addon.id }, options) end
+function PluginManager:unstub(addon, options) return run_stateful_plugin_command(self, "unstub", { addon.id }, options) end
function PluginManager:get_addon(name_and_version)
diff --git a/plugins/plugin_manager/plugin_view.lua b/plugins/plugin_manager/plugin_view.lua
index d223be6..31e3550 100644
--- a/plugins/plugin_manager/plugin_view.lua
+++ b/plugins/plugin_manager/plugin_view.lua
@@ -219,6 +219,14 @@ function PluginView:uninstall(plugin)
end
+function PluginView:unstub(plugin)
+ self.loading = true
+ self.plugin_manager:unstub(plugin, { progress = self.progress_callback }):done(function()
+ self.loading = false
+ self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil
+ end)
+end
+
function PluginView:reinstall(plugin)
self.loading = true
self.plugin_manager:reinstall(plugin, { progress = self.progress_callback }):done(function()
@@ -330,6 +338,20 @@ end, {
end
end
if not opened then core.error("Can't find source for plugin.") end
+ end,
+ ["plugin-manager:view-readme-hovered"] = function()
+ local directory = plugin_view.hovered_plugin.type == "library" and "libraries" or "plugins"
+ local opened = false
+ plugin_view.hovered_plugin:unstub(plugin_view.hovered_plugin):done(function(plugin)
+ for i, path in ipairs({ plugin_view.hovered_plugin.path .. PATHSEP .. "README.md" }) do
+ local stat = system.get_file_info(path)
+ if stat and stat.type == "file" then
+ core.root_view:open_doc(core.open_doc(path))
+ opened = true
+ end
+ end
+ if not opened then core.error("Can't find README for plugin.") end
+ end)
end
})
@@ -354,6 +376,7 @@ PluginView.menu:register(nil, {
{ text = "Install", command = "plugin-manager:install-hovered" },
{ text = "Uninstall", command = "plugin-manager:uninstall-hovered" },
{ text = "View Source", command = "plugin-manager:view-source-hovered" },
+ { text = "View README", command = "plugin-manager:view-readme-hovered" },
ContextMenu.DIVIDER,
{ text = "Refresh Listing", command = "plugin-manager:refresh-all" },
{ text = "Upgrade All", command = "plugin-manager:upgrade-all" },