aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2022-10-29 14:29:07 -0400
committerAdam Harrison <adamdharrison@gmail.com>2022-10-29 14:29:07 -0400
commita1718a858d002bc722d147f5eeb1a32449ab139e (patch)
tree435395ce18dca779a9b5cca7763911f37ff00c6c /plugins
parent9edba77d479a5c884d521fce2b2948eb197da5e8 (diff)
downloadlite-xl-plugin-manager-a1718a858d002bc722d147f5eeb1a32449ab139e.tar.gz
lite-xl-plugin-manager-a1718a858d002bc722d147f5eeb1a32449ab139e.zip
Fixed plugin_manager somewhat.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugin_manager/init.lua25
-rw-r--r--plugins/plugin_manager/plugin_view.lua9
2 files changed, 25 insertions, 9 deletions
diff --git a/plugins/plugin_manager/init.lua b/plugins/plugin_manager/init.lua
index 11a6304..5472798 100644
--- a/plugins/plugin_manager/init.lua
+++ b/plugins/plugin_manager/init.lua
@@ -73,6 +73,8 @@ local function run(cmd)
table.insert(cmd, "--mod-version=" .. MOD_VERSION)
table.insert(cmd, "--quiet")
table.insert(cmd, "--userdir=" .. USERDIR)
+ table.insert(cmd, "--datadir=" .. DATADIR)
+ table.insert(cmd, "--binary=" .. EXEFILE)
table.insert(cmd, "--assume-yes")
if config.plugins.plugin_manager.ssl_certs then table.insert(cmd, "--ssl_certs") table.insert(cmd, config.plugins.plugin_manager.ssl_certs) end
if config.plugins.plugin_manager.force then table.insert(cmd, "--force") end
@@ -131,12 +133,15 @@ function PluginManager:refresh()
for i, plugin in ipairs(self.plugins) do
if plugin.status ~= "incompatible" then
table.insert(self.valid_plugins, plugin)
+ if plugin.name == "plugin_manager" and plugin.status == "installed" then
+ plugin.status = "special"
+ end
end
end
self.last_refresh = os.time()
prom:resolve(plugins)
run({ "repo", "list" }):done(function(repositories)
- self.repositories = repositories
+ self.repositories = json.decode(repositories)["repositories"]
end)
end)
return prom
@@ -200,6 +205,7 @@ PluginManager.view = require "plugins.plugin_manager.plugin_view"
command.add(nil, {
["plugin-manager:install"] = function()
+ PluginManager:get_plugins()
core.command_view:enter("Enter plugin name",
function(name)
PluginManager:get_plugin(name):done(function(plugin)
@@ -215,7 +221,7 @@ command.add(nil, {
local items = {}
if not PluginManager.plugins then return end
for i, plugin in ipairs(PluginManager.plugins) do
- if not plugin.mod_version or tostring(plugin.mod_version) == tostring(MOD_VERSION) then
+ if not plugin.mod_version or tostring(plugin.mod_version) == tostring(MOD_VERSION) and plugin.status == "available" then
table.insert(items, plugin.name .. ":" .. plugin.version)
end
end
@@ -224,6 +230,7 @@ command.add(nil, {
)
end,
["plugin-manager:uninstall"] = function()
+ PluginManager:get_plugins()
core.command_view:enter("Enter plugin name",
function(name)
PluginManager:get_plugin(name):done(function(plugin)
@@ -253,19 +260,25 @@ command.add(nil, {
PluginManager:add(url):done(function()
core.log("Successfully added repository " .. url .. ".")
end)
- end,
- function(text) return get_suggestions(text) end
+ end
)
end,
["plugin-manager:remove-repository"] = function()
+ PluginManager:get_plugins()
core.command_view:enter("Enter repository url",
function(url)
- PluginManager:add(url):done(function()
+ PluginManager:remove(url):done(function()
core.log("Successfully removed repository " .. url .. ".")
end)
end,
function(text)
- return get_suggestions(text)
+ local items = {}
+ if PluginManager.repositories then
+ for i,v in ipairs(PluginManager.repositories) do
+ table.insert(items, v.remote .. ":" .. (v.commit or v.branch))
+ end
+ end
+ return common.fuzzy_match(items, text)
end
)
end,
diff --git a/plugins/plugin_manager/plugin_view.lua b/plugins/plugin_manager/plugin_view.lua
index 19eb9ae..3972cf4 100644
--- a/plugins/plugin_manager/plugin_view.lua
+++ b/plugins/plugin_manager/plugin_view.lua
@@ -157,7 +157,10 @@ function PluginView:draw()
end
x = x + style.padding.x
for j, v in ipairs({ get_plugin_text(plugin) }) do
- local color = (plugin.status == "installed" or plugin.status == "orphan") and style.good or (plugin.status == "core" and style.warn or style.text)
+ local color = (plugin.status == "installed" or plugin.status == "orphan") and style.good or
+ (plugin.status == "core" and style.warn or
+ (plugin.status == "special" and style.modified or style.text)
+ )
if self.loading then color = mul(color, style.dim) end
common.draw_text(style.font, color, v, "left", x, y, self.widths[j], lh)
x = x + self.widths[j] + style.padding.x
@@ -234,12 +237,12 @@ end, {
["plugin-manager:reinstall-hovered"] = function() plugin_view:reinstall(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" or plugin_view.hovered_plugin.status == "core" or plugin_view.hovered_plugin.status == "orphan")
+ return core.active_view and core.active_view:is(PluginView) and plugin_view.hovered_plugin
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
+ for i, path in ipairs({ plugin_view.hovered_plugin.path, plugin_view.hovered_plugin.path .. 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))