aboutsummaryrefslogtreecommitdiff
path: root/plugins/plugin_manager/plugin_view.lua
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2022-09-18 18:16:48 -0400
committerAdam <adamdharrison@gmail.com>2022-09-18 18:16:48 -0400
commita1feb9696cbbffc3ba061dcffc5a0ada9891fb22 (patch)
tree8cc4cc473e9d7e2e91f862e875d61a32de5fecb7 /plugins/plugin_manager/plugin_view.lua
parentda37e3ed1e11853c5133c9851a4fc2dbf2ca8872 (diff)
downloadlite-xl-plugin-manager-a1feb9696cbbffc3ba061dcffc5a0ada9891fb22.tar.gz
lite-xl-plugin-manager-a1feb9696cbbffc3ba061dcffc5a0ada9891fb22.zip
Probably last update before release.
Diffstat (limited to 'plugins/plugin_manager/plugin_view.lua')
-rw-r--r--plugins/plugin_manager/plugin_view.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/plugins/plugin_manager/plugin_view.lua b/plugins/plugin_manager/plugin_view.lua
index f661b00..7e7f04d 100644
--- a/plugins/plugin_manager/plugin_view.lua
+++ b/plugins/plugin_manager/plugin_view.lua
@@ -26,7 +26,8 @@ PluginView.menu = ContextMenu()
PluginView.menu:register(nil, {
{ text = "Install", command = "plugin-manager:install-hovered" },
- { text = "Uninstall", command = "plugin-manager:uninstall-hovered" }
+ { text = "Uninstall", command = "plugin-manager:uninstall-hovered" },
+ { text = "View Source", command = "plugin-manager:view-source-hovered" }
})
function PluginView:new()
@@ -189,7 +190,6 @@ command.add(nil, {
end
})
-
command.add(PluginView, {
["plugin-manager:select"] = function(x, y)
plugin_view.selected_plugin, plugin_view.selected_plugin_idx = plugin_view.hovered_plugin, plugin_view.hovered_plugin_idx
@@ -215,6 +215,22 @@ command.add(function()
end, {
["plugin-manager:uninstall-hovered"] = function() plugin_view:uninstall(plugin_view.hovered_plugin) end
})
+command.add(function()
+ return core.active_view and core.active_view:is(PluginView) and plugin_view.hovered_plugin and plugin_view.hovered_plugin.status == "installed"
+end, {
+ ["plugin-manager:view-source-hovered"] = function()
+ local directory = plugin_view.hovered_plugin.type == "library" and "libraries" or "plugins"
+ local opened = false
+ for i, path in ipairs({ USERDIR .. PATHSEP .. directory .. PATHSEP .. plugin_view.hovered_plugin.name .. ".lua", USERDIR .. PATHSEP .. directory .. PATHSEP .. plugin_view.hovered_plugin.name .. PATHSEP .. "init.lua" }) 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 source for plugin.") end
+ end
+})
keymap.add {