aboutsummaryrefslogtreecommitdiff
path: root/plugins/plugin_manager
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2023-12-04 16:51:30 -0500
committerGitHub <noreply@github.com>2023-12-04 16:51:30 -0500
commit7d7defca57e26b89087fe5ef656a405d0ee8ed78 (patch)
treef3ff56d9343cb35f7a0a5588f83c0b71ef51d8ef /plugins/plugin_manager
parentdba23140b99d1195f570bb76aa19a9091d4ced5d (diff)
parent134fdfa3e1622a21049ec1789624c8eb98b76278 (diff)
downloadlite-xl-plugin-manager-7d7defca57e26b89087fe5ef656a405d0ee8ed78.tar.gz
lite-xl-plugin-manager-7d7defca57e26b89087fe5ef656a405d0ee8ed78.zip
Merge pull request #32 from lite-xl/PR/welcome-plugin
Welcome Plugin
Diffstat (limited to 'plugins/plugin_manager')
-rw-r--r--plugins/plugin_manager/init.lua17
-rw-r--r--plugins/plugin_manager/plugin_view.lua21
2 files changed, 25 insertions, 13 deletions
diff --git a/plugins/plugin_manager/init.lua b/plugins/plugin_manager/init.lua
index e30d7f6..76f799a 100644
--- a/plugins/plugin_manager/init.lua
+++ b/plugins/plugin_manager/init.lua
@@ -5,6 +5,7 @@ local common = require "core.common"
local config = require "core.config"
local command = require "core.command"
local json = require "libraries.json"
+local keymap = require "core.keymap"
local PluginManager = {
@@ -128,7 +129,11 @@ local function run(cmd, progress)
local err = v[1]:read_stderr(2048)
core.error("error running " .. join(" ", cmd) .. ": " .. (err or "?"))
progress_line, v[3] = extract_progress(v[3])
- v[2]:reject(v[3])
+ if err then
+ v[2]:reject(json.decode(err).error)
+ else
+ v[2]:reject(err)
+ end
end
break
end
@@ -195,7 +200,7 @@ function PluginManager:get_addons(options)
else
self:refresh(options):done(function()
prom:resolve(self.addons)
- end)
+ end):fail(function(arg) promise:reject(arg) end)
end
return prom
end
@@ -208,6 +213,8 @@ local function run_stateful_plugin_command(plugin_manager, cmd, args, options)
else
plugin_manager:refresh(options):forward(promise)
end
+ end):fail(function(arg)
+ promise:reject(arg)
end)
return promise
end
@@ -225,7 +232,7 @@ function PluginManager:unstub(addon, options)
local unstubbed_addon = json.decode(result).addons[1]
for k,v in pairs(unstubbed_addon) do addon[k] = v end
promise:resolve(addon)
- end)
+ end):fail(function(arg) promise:reject(arg) end)
end
return promise
end
@@ -249,7 +256,7 @@ function PluginManager:get_addon(name_and_version, options)
end
end
if not match then promise:reject() end
- end)
+ end):fail(function(arg) promise:reject(arg) end)
return promise
end
@@ -347,7 +354,7 @@ command.add(nil, {
if pcall(require, "plugins.terminal") then
local terminal = require "plugins.terminal"
command.add(nil, {
- ["plugin-manager:session"] = function()
+ ["plugin-manager:open-session"] = function()
local arguments = { "-" }
for i,v in ipairs(default_arguments) do table.insert(arguments, v) end
local tv = terminal.class(common.merge(config.plugins.terminal, {
diff --git a/plugins/plugin_manager/plugin_view.lua b/plugins/plugin_manager/plugin_view.lua
index 9e9d67c..f8f503b 100644
--- a/plugins/plugin_manager/plugin_view.lua
+++ b/plugins/plugin_manager/plugin_view.lua
@@ -145,20 +145,25 @@ local function draw_loading_bar(x, y, width, height, percent)
renderer.draw_rect(x, y, width * percent, height, style.caret)
end
+function PluginView:draw_loading_screen(label, percent)
+ common.draw_text(style.big_font, style.dim, "Loading...", "center", self.position.x, self.position.y, self.size.x, self.size.y)
+ local width = self.size.x / 2
+ local offset_y = self.size.y / 2
+ if label or percent then
+ local th = style.font:get_height()
+ local lh = th + style.padding.y
+ common.draw_text(style.font, style.dim, label, "center", self.position.x, self.position.y + offset_y + lh, self.size.x, lh)
+ draw_loading_bar(self.position.x + (self.size.x / 2) - (width / 2), self.position.y + self.size.y / 2 + (lh * 2), width, lh, percent)
+ end
+end
+
function PluginView:draw()
self:draw_background(style.background)
local th = style.font:get_height()
local lh = th + style.padding.y
if not self.initialized or not self.widths then
- common.draw_text(style.big_font, style.dim, "Loading...", "center", self.position.x, self.position.y, self.size.x, self.size.y)
- local width = self.size.x / 2
- local offset_y = self.size.y / 2
- if self.progress then
- common.draw_text(style.font, style.dim, self.progress.label, "center", self.position.x, self.position.y + offset_y + lh, self.size.x, lh)
- draw_loading_bar(self.position.x + (self.size.x / 2) - (width / 2), self.position.y + self.size.y / 2 + (lh * 2), width, lh, self.progress.percent)
- end
- return
+ return self:draw_loading_screen(self.progress and self.progress.label, self.progress and self.progress.percent)
end