aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-06-27 10:26:42 -0400
committerAdam Harrison <adamdharrison@gmail.com>2023-06-27 10:26:42 -0400
commit02586b9fa37bc6ad42bd1e59321bb2334bec6433 (patch)
treee348a62d8cb87b4914b27bdf6fc1825b53812cb4
parentf69e69b5bb5ecff0bf8154b9aab0e1c8a1dc265e (diff)
downloadlite-xl-plugin-manager-02586b9fa37bc6ad42bd1e59321bb2334bec6433.tar.gz
lite-xl-plugin-manager-02586b9fa37bc6ad42bd1e59321bb2334bec6433.zip
Fixed some minor bugs, moved json to a library, updated manifest to reflect this.
-rwxr-xr-xbuild.sh2
-rw-r--r--libraries/json.lua (renamed from plugins/json.lua)0
-rw-r--r--manifest.json2
-rw-r--r--plugins/plugin_manager/init.lua34
-rw-r--r--plugins/plugin_manager/plugin_view.lua10
-rw-r--r--src/lpm.lua22
6 files changed, 41 insertions, 29 deletions
diff --git a/build.sh b/build.sh
index 6805532..e04999c 100755
--- a/build.sh
+++ b/build.sh
@@ -21,7 +21,7 @@ if [[ "$@" != *"-lz"* ]]; then
[[ ! -e "lib/zlib/build" && $OSTYPE != 'msys'* ]] && cd lib/zlib && mkdir build && cd build && $CC $CFLAGS -O3 -D_LARGEFILE64_SOURCE -I.. ../*.c -c && $AR rc libz.a *.o && cp libz.a ../../prefix/lib && cp ../*.h ../../prefix/include && cd ../../../
LDFLAGS="$LDFLAGS -lz"
fi
-if [[ "$@" != *"-lmbedtls"* && "$@" != *"-lmbedcrypto"* ]]; then
+if [[ "$@" != *"-lmbedtls"* && "$@" != *"-lmbedcrypto"* && "$@" != *"-lmbedx509"* ]]; then
[ ! -e "lib/mbedtls-2.27.0/build" ] && cd lib/mbedtls-2.27.0 && mkdir build && cd build && CFLAGS="$CFLAGS $CFLAGS_MBEDTLS -DMBEDTLS_MD4_C=1 -w" cmake .. $CMAKE_DEFAULT_FLAGS -G "Unix Makefiles" -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF $SSL_CONFIGURE && CFLAGS="$CFLAGS $CFLAGS_MBEDTLS -DMBEDTLS_MD4_C=1 -w" $MAKE -j $JOBS && $MAKE install && cd ../../../
LDFLAGS="$LDFLAGS -lmbedtls -lmbedx509 -lmbedcrypto"
fi
diff --git a/plugins/json.lua b/libraries/json.lua
index c463440..c463440 100644
--- a/plugins/json.lua
+++ b/libraries/json.lua
diff --git a/manifest.json b/manifest.json
index f673672..6686487 100644
--- a/manifest.json
+++ b/manifest.json
@@ -65,7 +65,7 @@
"version": "1.0",
"description": "JSON support plugin, provides encoding/decoding.",
"type": "library",
- "path": "plugins/json.lua"
+ "path": "libraries/json.lua"
}
],
"lite-xls": [
diff --git a/plugins/plugin_manager/init.lua b/plugins/plugin_manager/init.lua
index ae8343d..87c2bad 100644
--- a/plugins/plugin_manager/init.lua
+++ b/plugins/plugin_manager/init.lua
@@ -166,10 +166,10 @@ function PluginManager:refresh(progress)
end
-function PluginManager:upgrade(progress)
+function PluginManager:upgrade(options)
local prom = Promise.new()
- run({ "update" }, progress):done(function()
- run({ "upgrade" }, progress):done(function()
+ run({ "update" }, options.progress):done(function()
+ run({ "upgrade" }, options.progress):done(function()
prom:resolve()
end)
end)
@@ -178,8 +178,8 @@ end
-function PluginManager:purge(progress)
- return run({ "purge" }, progress)
+function PluginManager:purge(options)
+ return run({ "purge" }, options.progress)
end
@@ -195,22 +195,22 @@ function PluginManager:get_addons()
return prom
end
-local function run_stateful_plugin_command(plugin_manager, cmd, arg, progress)
+local function run_stateful_plugin_command(plugin_manager, cmd, arg, options)
local promise = Promise.new()
- run({ cmd, arg }, progress):done(function(result)
- if config.plugins.plugin_manager.restart_on_change then
+ run({ cmd, arg }, 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
- plugin_manager:refresh(progress):forward(promise)
+ plugin_manager:refresh(options):forward(promise)
end
end)
return promise
end
-function PluginManager:install(addon, progress) return run_stateful_plugin_command(self, "install", addon.id .. (addon.version and (":" .. addon.version) or ""), progress) end
-function PluginManager:uninstall(addon, progress) return run_stateful_plugin_command(self, "uninstall", addon.id, progress) end
-function PluginManager:reinstall(addon, progress) return run_stateful_plugin_command(self, "reinstall", addon.id, progress) 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:get_addon(name_and_version)
@@ -245,7 +245,7 @@ command.add(nil, {
function(name)
PluginManager:get_addon(name):done(function(addon)
core.log("Attempting to install plugin " .. name .. "...")
- PluginManager:install(addon, PluginManager.view.progress_callback):done(function()
+ PluginManager:install(addon, { progress = PluginManager.view.progress_callback }):done(function()
core.log("Successfully installed plugin " .. addon.id .. ".")
end)
end):fail(function()
@@ -270,7 +270,7 @@ command.add(nil, {
function(name)
PluginManager:get_addon(name):done(function(addon)
core.log("Attempting to uninstall plugin " .. addon.id .. "...")
- PluginManager:uninstall(addon, PluginManager.view.progress_callback):done(function()
+ PluginManager:uninstall(addon, { progress = PluginManager.view.progress_callback }):done(function()
core.log("Successfully uninstalled plugin " .. addon.id .. ".")
end)
end):fail(function()
@@ -317,9 +317,9 @@ command.add(nil, {
end
)
end,
- ["plugin-manager:refresh"] = function() PluginManager:refresh(PluginManager.view.progress_callback):done(function() core.log("Successfully refreshed plugin listing.") end) end,
- ["plugin-manager:upgrade"] = function() PluginManager:upgrade(PluginManager.view.progress_callback):done(function() core.log("Successfully upgraded installed plugins.") end) end,
- ["plugin-manager:purge"] = function() PluginManager:purge(PluginManager.view.progress_callback):done(function() core.log("Successfully purged lpm directory.") end) end,
+ ["plugin-manager:refresh"] = function() PluginManager:refresh({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully refreshed plugin listing.") end) end,
+ ["plugin-manager:upgrade"] = function() PluginManager:upgrade({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully upgraded installed plugins.") end) end,
+ ["plugin-manager:purge"] = function() PluginManager:purge({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully purged lpm directory.") end) end,
["plugin-manager:show"] = function()
local node = core.root_view:get_active_node_default()
node:add_view(PluginManager.view(PluginManager))
diff --git a/plugins/plugin_manager/plugin_view.lua b/plugins/plugin_manager/plugin_view.lua
index 1f16b3c..d223be6 100644
--- a/plugins/plugin_manager/plugin_view.lua
+++ b/plugins/plugin_manager/plugin_view.lua
@@ -96,7 +96,7 @@ end
function PluginView:refresh()
self.loading = true
- return self.plugin_manager:refresh(self.progress_callback):done(function()
+ return self.plugin_manager:refresh({ progress = self.progress_callback }):done(function()
self.loading = false
self.initialized = true
self.widths = {}
@@ -204,7 +204,7 @@ end
function PluginView:install(plugin)
self.loading = true
- self.plugin_manager:install(plugin, self.progress_callback):done(function()
+ self.plugin_manager:install(plugin, { progress = self.progress_callback }):done(function()
self.loading = false
self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil
end)
@@ -212,7 +212,7 @@ end
function PluginView:uninstall(plugin)
self.loading = true
- self.plugin_manager:uninstall(plugin, self.progress_callback):done(function()
+ self.plugin_manager:uninstall(plugin, { progress = self.progress_callback }):done(function()
self.loading = false
self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil
end)
@@ -221,7 +221,7 @@ end
function PluginView:reinstall(plugin)
self.loading = true
- self.plugin_manager:reinstall(plugin, self.progress_callback):done(function()
+ self.plugin_manager:reinstall(plugin, { progress = self.progress_callback }):done(function()
self.loading = false
self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil
end)
@@ -230,7 +230,7 @@ end
function PluginView:upgrade()
self.loading = true
- return self.plugin_manager:upgrade(self.progress_callback):done(function()
+ return self.plugin_manager:upgrade({ progress = self.progress_callback }):done(function()
self.loading = false
self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil
end)
diff --git a/src/lpm.lua b/src/lpm.lua
index 5be0051..c0690ae 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -993,7 +993,10 @@ end
function Repository.url(url)
if type(url) == "table" then return (url.remote and (url.remote .. ":" .. (url.branch or url.commit)) or url.repo_path) end
- if not url:find("^%a+:") then return Repository.new({ repo_path = url:gsub("[/\\]$", "") }) end
+ if not url:find("^%a+:") then
+ local stat = system.stat(url:gsub("[/\\]$", "")) or error("can't find repository " .. url)
+ return Repository.new({ repo_path = stat.abs_path })
+ end
local e = url:reverse():find(":")
local s = e and (#url - e + 1)
local remote, branch_or_commit = url:sub(1, s and (s-1) or #url), s and url:sub(s+1)
@@ -2233,13 +2236,22 @@ not commonly used publically.
local system_lite_xl = common.first(common.concat(common.flat_map(repositories, function(r) return r.lite_xls end), lite_xls), function(lite_xl) return lite_xl:get_binary_path() == lite_xl_binary end)
if not system_lite_xl then
system_lite_xl = common.first(lite_xls, function(e) return e.version == "system" end)
- if system_lite_xl then error("can't find existing system lite (does " .. system_lite_xl:get_binary_path() .. " exist? was it moved?); run `lpm purge`, or specify --binary and --datadir.") end
+
local directory = common.dirname(lite_xl_binary)
local lite_xl_datadirs = { DATADIR, directory .. PATHSEP .. "data", directory:find(PATHSEP .. "bin$") and common.dirname(directory .. PATHSEP .. "share" .. PATHSEP .. "lite-xl"), directory .. PATHSEP .. "data" }
local lite_xl_datadir = common.first(lite_xl_datadirs, function(p) return p and system.stat(p) end)
- system_lite_xl = LiteXL.new(nil, { path = directory, datadir_path = lite_xl_datadir, binary_path = { [_G.ARCH] = lite_xl_binary }, mod_version = MOD_VERSION or LATEST_MOD_VERSION, version = "system", tags = { "system", "local" } })
- table.insert(lite_xls, system_lite_xl)
- lpm_lite_xl_save()
+
+ if not BINARY and not DATADIR and system_lite_xl then error("can't find existing system lite (does " .. system_lite_xl:get_binary_path() .. " exist? was it moved?); run `lpm purge`, or specify --binary and --datadir.") end
+ local detected_lite_xl = LiteXL.new(nil, { path = directory, datadir_path = lite_xl_datadir, binary_path = { [_G.ARCH] = lite_xl_binary }, mod_version = MOD_VERSION or LATEST_MOD_VERSION, version = "system", tags = { "system", "local" } })
+ if not system_lite_xl then
+ system_lite_xl = detected_lite_xl
+ table.insert(lite_xls, system_lite_xl)
+ lpm_lite_xl_save()
+ else
+ lite_xls = common.grep(lite_xls, function(e) return e ~= system_lite_xl end)
+ system_lite_xl = detected_lite_xl
+ table.insert(lite_xls, system_lite_xl)
+ end
else
if DATADIR then system_lite_xl.datadir_path = DATADIR end
table.insert(system_lite_xl.tags, "system")