mirror of
https://github.com/taigrr/glaze.nvim.git
synced 2026-04-14 00:48:39 -07:00
Compare commits
3 Commits
cd/bugfixe
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9463ba2b4b | |||
| bb82cde133 | |||
| 9e7f655026 |
25
.github/workflows/ci.yml
vendored
Normal file
25
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check formatting with StyLua
|
||||||
|
uses: JohnnyMorganz/stylua-action@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: latest
|
||||||
|
args: --check .
|
||||||
|
|
||||||
|
- name: Lint with luacheck
|
||||||
|
uses: lunarmodules/luacheck@v1
|
||||||
|
with:
|
||||||
|
args: lua/
|
||||||
7
.luacheckrc
Normal file
7
.luacheckrc
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
std = "luajit"
|
||||||
|
globals = { "vim" }
|
||||||
|
max_line_length = 150
|
||||||
|
|
||||||
|
ignore = {
|
||||||
|
"212", -- unused argument (common in callbacks)
|
||||||
|
}
|
||||||
6
.stylua.toml
Normal file
6
.stylua.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
column_width = 120
|
||||||
|
line_endings = "Unix"
|
||||||
|
indent_type = "Spaces"
|
||||||
|
indent_width = 2
|
||||||
|
quote_style = "AutoPreferDouble"
|
||||||
|
call_parentheses = "Always"
|
||||||
@@ -141,12 +141,13 @@ function M.refresh_version(name, callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
get_installed_version(name, function(installed)
|
get_installed_version(name, function(installed)
|
||||||
local info = M._update_info[name] or {
|
local info = M._update_info[name]
|
||||||
name = name,
|
or {
|
||||||
installed_version = nil,
|
name = name,
|
||||||
latest_version = nil,
|
installed_version = nil,
|
||||||
has_update = false,
|
latest_version = nil,
|
||||||
}
|
has_update = false,
|
||||||
|
}
|
||||||
info.installed_version = installed
|
info.installed_version = installed
|
||||||
|
|
||||||
-- If we have latest version cached, check if still needs update
|
-- If we have latest version cached, check if still needs update
|
||||||
|
|||||||
@@ -72,9 +72,7 @@ function M.check()
|
|||||||
else
|
else
|
||||||
vim.health.ok(count .. " binary(ies) registered")
|
vim.health.ok(count .. " binary(ies) registered")
|
||||||
for name, binary in pairs(binaries) do
|
for name, binary in pairs(binaries) do
|
||||||
local pi = (binary.plugins and #binary.plugins > 0)
|
local pi = (binary.plugins and #binary.plugins > 0) and (" (" .. table.concat(binary.plugins, ", ") .. ")") or ""
|
||||||
and (" (" .. table.concat(binary.plugins, ", ") .. ")")
|
|
||||||
or ""
|
|
||||||
if glaze.is_installed(name) then
|
if glaze.is_installed(name) then
|
||||||
vim.health.ok(" " .. name .. " — installed" .. pi)
|
vim.health.ok(" " .. name .. " — installed" .. pi)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -85,6 +85,12 @@ M._binaries = {}
|
|||||||
---@type number?
|
---@type number?
|
||||||
M._ns = nil
|
M._ns = nil
|
||||||
|
|
||||||
|
---@type table<string, boolean> Binaries queued for auto-install
|
||||||
|
M._auto_install_queue = {}
|
||||||
|
|
||||||
|
---@type number? Timer for batched auto-install
|
||||||
|
M._auto_install_timer = nil
|
||||||
|
|
||||||
---@param opts? GlazeConfig
|
---@param opts? GlazeConfig
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
||||||
@@ -184,16 +190,31 @@ function M.register(name, url, opts)
|
|||||||
callbacks = opts.callback and { [plugin] = opts.callback } or {},
|
callbacks = opts.callback and { [plugin] = opts.callback } or {},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Auto-install if enabled and binary is missing
|
-- Queue for auto-install if enabled and binary is missing.
|
||||||
|
-- Uses a batched timer so multiple registers don't race.
|
||||||
if M.config.auto_install.enabled and not M.is_installed(name) then
|
if M.config.auto_install.enabled and not M.is_installed(name) then
|
||||||
vim.defer_fn(function()
|
M._auto_install_queue[name] = true
|
||||||
if not M.is_installed(name) then
|
if M._auto_install_timer then
|
||||||
if not M.config.auto_install.silent then
|
vim.fn.timer_stop(M._auto_install_timer)
|
||||||
vim.notify("[glaze] Auto-installing " .. name .. "…", vim.log.levels.INFO)
|
end
|
||||||
|
M._auto_install_timer = vim.fn.timer_start(200, function()
|
||||||
|
M._auto_install_timer = nil
|
||||||
|
vim.schedule(function()
|
||||||
|
local to_install = {}
|
||||||
|
for queued_name, _ in pairs(M._auto_install_queue) do
|
||||||
|
if not M.is_installed(queued_name) then
|
||||||
|
table.insert(to_install, queued_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
require("glaze.runner").install({ name })
|
M._auto_install_queue = {}
|
||||||
end
|
if #to_install > 0 then
|
||||||
end, 100)
|
if not M.config.auto_install.silent then
|
||||||
|
vim.notify("[glaze] Auto-installing " .. table.concat(to_install, ", ") .. "…", vim.log.levels.INFO)
|
||||||
|
end
|
||||||
|
require("glaze.runner").install(to_install, { silent = M.config.auto_install.silent })
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -143,12 +143,16 @@ end
|
|||||||
---Run tasks for specified binaries.
|
---Run tasks for specified binaries.
|
||||||
---@param names string[]
|
---@param names string[]
|
||||||
---@param mode "install"|"update"
|
---@param mode "install"|"update"
|
||||||
local function run(names, mode)
|
---@param opts? { silent?: boolean }
|
||||||
|
local function run(names, mode, opts)
|
||||||
|
opts = opts or {}
|
||||||
local glaze = require("glaze")
|
local glaze = require("glaze")
|
||||||
|
|
||||||
-- Reject if already running (race condition fix)
|
-- Reject if already running (race condition fix)
|
||||||
if M._running then
|
if M._running then
|
||||||
vim.notify("Glaze: tasks already running. Wait or abort first.", vim.log.levels.WARN)
|
if not opts.silent then
|
||||||
|
vim.notify("Glaze: tasks already running. Wait or abort first.", vim.log.levels.WARN)
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -164,18 +168,18 @@ local function run(names, mode)
|
|||||||
for _, name in ipairs(names) do
|
for _, name in ipairs(names) do
|
||||||
local binary = glaze._binaries[name]
|
local binary = glaze._binaries[name]
|
||||||
if binary then
|
if binary then
|
||||||
if mode == "install" and glaze.is_installed(name) then
|
if not (mode == "install" and glaze.is_installed(name)) then
|
||||||
-- Skip already installed
|
|
||||||
else
|
|
||||||
table.insert(binaries, binary)
|
table.insert(binaries, binary)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
vim.notify("Unknown binary: " .. name, vim.log.levels.WARN)
|
if not opts.silent then
|
||||||
|
vim.notify("Unknown binary: " .. name, vim.log.levels.WARN)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #binaries == 0 then
|
if #binaries == 0 then
|
||||||
if mode == "install" then
|
if mode == "install" and not opts.silent then
|
||||||
vim.notify("All binaries already installed", vim.log.levels.INFO)
|
vim.notify("All binaries already installed", vim.log.levels.INFO)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
@@ -191,8 +195,10 @@ local function run(names, mode)
|
|||||||
M._notify()
|
M._notify()
|
||||||
M._process_queue()
|
M._process_queue()
|
||||||
|
|
||||||
-- Open UI
|
-- Open UI (skip for silent/auto-install operations)
|
||||||
require("glaze.view").open()
|
if not opts.silent then
|
||||||
|
require("glaze.view").open()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Update specific binaries.
|
---Update specific binaries.
|
||||||
@@ -209,8 +215,9 @@ end
|
|||||||
|
|
||||||
---Install specific binaries.
|
---Install specific binaries.
|
||||||
---@param names string[]
|
---@param names string[]
|
||||||
function M.install(names)
|
---@param opts? { silent?: boolean }
|
||||||
run(names, "install")
|
function M.install(names, opts)
|
||||||
|
run(names, "install", opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Install all missing binaries.
|
---Install all missing binaries.
|
||||||
|
|||||||
Reference in New Issue
Block a user