Add example usage and change disclaimer

pull/1/head
delta 2 months ago
parent 4a2fde95bf
commit 0c1a51caf5
  1. 21
      README.md
  2. 137
      init.lua

@ -1,8 +1,27 @@
<h1 align="center">💡 lite-bulb</h1>
<p align="center">minimalist, vim-plug inspired plugin manager for lite-xl</p>
DISCLAIMER: THIS PLUGIN DOES NOT SUPPORT WINDOWS, AND I AM NOT PLANNING ON SUPPORTING IT ANY TIME SOON
DISCLAIMER: This plugin doesn't support windows yet and i'm not planning on implementing windows support myself. If you want Windows support make a PR.
Example usage:
```lua
config.plugins.bulb.plugins = {
"torchedsammy/evergreen.lxl", -- Supports shorthand format for plugin URLs (defaults to https://github.com/<shorthand>)
"https://git.karx.xyz/delta/lite-bulb", -- Bulb can self-manage itself
{ "lite-xl/lite-xl-lsp",
requires = { "lite-xl/widgets", -- Specify dependencies
{ "liquidev/lintplus", opt = true } }
},
{ "lite-xl/console", commit = "102129c" }, -- Specify plugin version via commit hashes or git tags
{ "torchedsammy/litepresence", run = "cd litepresence && go get && go build" } -- run shell commands post-installation/update
{ "lite-xl/lite-xl-plugins", branch = "2.1", files = { "plugins/minimap.lua", "plugins/bracketmatch.lua" } } -- Get individual files from a repo
}
```
![License](https://img.shields.io/github/license/delta-official/syrup?color=%23f5ad44&labelColor=%23222831&style=for-the-badge)

@ -2,14 +2,8 @@
local config = require "core.config"
local common = require "core.common"
local core = require "core"
-- local system = require "system"
local os = require "os"
-- TODO: Add config support
-- Options:
-- keep_plugins: <bool> -- Whether to keep plugins installed after delinking them | DEFAULT: true
-- plugins: <table: <string>=<float/int> > -- List of enabled plugins
-- Stolen™ from gitstatus plugin (slightly modified)
local function exec(cmd, opts)
local proc = process.start(cmd, opts)
@ -19,24 +13,21 @@ local function exec(cmd, opts)
return proc:returncode()
end
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local dev_null = { stdout = process.REDIRECT_DISCARD,
stderr = process.REDIRECT_DISCARD }
BULB_PLUGINS = USERDIR .. "/bulb-plugins/"
-- function Set (list)
-- local set = {}
-- for _, l in ipairs(list) do set[l] = true end
-- return set
-- end
local function git(subfunction, parameters)
os.execute("git " .. subfunction .. " " .. parameters or "" .. " >/dev/null 2>&1")
end
-- local function git(subfunction, parameters)
-- exec({"git", subfunction, parameters or ""},
-- { stdout = process.REDIRECT_DISCARD,
-- stderr = process.REDIRECT_DISCARD })
-- end
local function check_url(url)
local good_url
@ -47,22 +38,18 @@ local function check_url(url)
good_url = "https://github.com/" .. url
end
-- local url_exists = {os.execute("curl --head --silent --fail " .. good_url .. " >/dev/null 2>&1")}
local url_exists = exec({ "curl", "--head", "--silent", "--fail", good_url }, {})
if url_exists ~= 0 then
-- core.log(url_exists)
core.log(dump(url_exists))
-- core.log("curl --head --silent --fail " .. good_url .. " >/dev/null 2>&1")
core.error("Could not find plugin \"" .. good_url .. "\", check if the identifier is correct")
return "oopsy"
return nil
end
return good_url
end
config.plugins.bulb = common.merge({
keep_plugins = true,
-- keep_plugins = true,
-- plugins = {}
plugins = { "delta-official/lite-bulb", "https://git.karx.xyz/delta/lite-bulb", "https://git.karx.xyz/deez/nuts" } -- Format: <string>/{string + extra bs (see docs)} = <float/int>
}, config.plugins.bulb)
@ -70,62 +57,52 @@ config.plugins.bulb = common.merge({
-- So string is basically gonna have this format "<https://github.com/>username/repo<:FILE>"
-- where FILE is the file/list of files to symlink into plugins folder
core.add_thread(function()
local git_installed = exec({ "git", "help" },
{ stdout = process.REDIRECT_DISCARD,
stderr = process.REDIRECT_DISCARD })
local git_installed = exec({ "git", "help" }, dev_null)
if git_installed ~= 0 then
core.error("git is not installed, please install git to use bulb")
os.exit()
end
local curl_installed = exec({ "curl", "-h" },
{ stdout = process.REDIRECT_DISCARD,
stderr = process.REDIRECT_DISCARD })
if git_installed ~= 0 then
core.error("git is not installed. Please install git to use bulb")
os.exit()
end
if curl_installed ~= 0 then
core.error("curl is not installed, please install curl to use bulb")
os.exit()
end
local curl_installed = exec({ "curl", "-h" }, dev_null)
for _, plugin in ipairs(config.plugins.bulb.plugins) do
if type(plugin) == "string" then
-- git("clone", "")
core.log(plugin)
core.log(check_url(plugin))
if curl_installed ~= 0 then
core.error("curl is not installed. Please install curl to use bulb")
os.exit()
end
elseif type(plugin) == "table" then
end
end
for _, plugin in ipairs(config.plugins.bulb.plugins) do
local plugin_path = BULB_PLUGINS .. string.match(url, "/([^/]+)$")
if type(plugin) == "string" then
local url = check_url(plugin)
if url ~= nil then
exec({"git", "clone", url, plugin_path}, dev_null)
-- Fetch all repository tags
exec({"git", "-C", plugin_path, "fetch", "--tags"}, dev_null)
end
elseif type(plugin) == "table" then
if plugin.version and plugin.commit then --
-- If both plugin version and commit are supplied prefer hash over version
-- Also warn user that this is a bad config
exec({ "git", "-C", plugin_path, "checkout", plugin.hash }, dev_null)
core.warn("Specifying both plugin version and hash for \"" .. plugin .."\". This is not supported.")
elseif plugin.version then
-- switch to the specified version (tag)
exec({ "git", "-C", plugin_path, "c", plugin.version }, dev_null)
elseif plugin.hash then
-- switch to the specified version (commit)
exec({ "git", "-C", plugin_path, "checkout", plugin.commit }, dev_null)
end
end
-- Check if the bulb-plugins have any plugins not in the plugin list
for _, installed_plugin in ipairs() do
end
end
end)
local git_repo = "https://github.com/lite-xl/lite-xl-plugins"
-- local function exists(file)
-- local ok, err, code = os.rename(file, file)
-- if not ok then
-- if code == 13 then
-- -- Permission denied, but it exists
-- return true
-- end
-- end
-- return ok, err
-- end
-- if not exists
-- local bulb = {}
-- function bulb.validate_plugins()
-- for _, name in ipairs(config.plugins.bulb.plugins) do
-- end
-- end
---@param string plugin
-- function bulb(plugin)
-- end

Loading…
Cancel
Save