3 Commits

Author SHA1 Message Date
d94fee916b handle duplicate binaries 2026-02-19 01:07:47 -05:00
ea73ed51b1 Update badge URLs in README.md 2026-02-18 23:33:18 -05:00
5867abd592 Update copyright year in LICENSE file 2026-02-18 23:27:29 -05:00
6 changed files with 108 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
BSD Zero Clause License
Copyright (c) 2025 Tai Groot
Copyright (c) 2026 Tai Groot
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

View File

@@ -6,16 +6,16 @@
<p>
<a href="https://github.com/taigrr/glaze.nvim/releases/latest">
<img alt="Latest release" src="https://img.shields.io/github/v/release/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=FF6AD5&logoColor=D9E0EE&labelColor=302D41&include_prerelease&sort=semver">
<img alt="Latest release" src="https://img.shields.io/github/v/release/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=FF6AD5&logoColor=D9E0EE&labelColor=302D41&sort=semver&include_prerelease">
</a>
<a href="https://github.com/taigrr/glaze.nvim/pulse">
<img alt="Last commit" src="https://img.shields.io/github/last-commit/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=8bd5ca&logoColor=D9E0EE&labelColor=302D41">
<img alt="Last commit" src="https://img.shields.io/github/last-commit/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=8bd5ca&labelColor=302D41&logoColor=D9E0EE">
</a>
<a href="https://github.com/taigrr/glaze.nvim/blob/master/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=ee999f&logoColor=D9E0EE&labelColor=302D41">
<img alt="License" src="https://img.shields.io/github/license/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=ee999f&labelColor=302D41&logoColor=D9E0EE">
</a>
<a href="https://github.com/taigrr/glaze.nvim/stargazers">
<img alt="Stars" src="https://img.shields.io/github/stars/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=c69ff5&logoColor=D9E0EE&labelColor=302D41">
<img alt="Stars" src="https://img.shields.io/github/stars/taigrr/glaze.nvim?style=for-the-badge&logo=starship&color=c69ff5&labelColor=302D41&logoColor=D9E0EE">
</a>
</p>

View File

@@ -127,6 +127,60 @@ function M.get_update_info()
return M._update_info
end
---Refresh version info for a single binary (called after install/update).
---@param name string Binary name
---@param callback? fun() Optional callback when done
function M.refresh_version(name, callback)
local glaze = require("glaze")
local binary = glaze._binaries[name]
if not binary then
if callback then
callback()
end
return
end
get_installed_version(name, function(installed)
local info = M._update_info[name] or {
name = name,
installed_version = nil,
latest_version = nil,
has_update = false,
}
info.installed_version = installed
-- If we have latest version cached, check if still needs update
if info.latest_version and installed then
info.has_update = installed ~= info.latest_version
else
info.has_update = false
end
M._update_info[name] = info
-- Persist to state
local state = read_state()
state.update_info = state.update_info or {}
state.update_info[name] = {
installed_version = info.installed_version,
latest_version = info.latest_version,
has_update = info.has_update,
}
write_state(state)
-- Refresh UI if open
vim.schedule(function()
local ok, view = pcall(require, "glaze.view")
if ok and view._float and view._float:valid() then
view.render()
end
if callback then
callback()
end
end)
end)
end
---Check for updates on all registered binaries.
---@param opts? { silent?: boolean }
function M.check(opts)

View File

@@ -15,8 +15,8 @@ local M = {}
---@class GlazeBinary
---@field name string Binary name (executable name)
---@field url string Go module URL (without @version)
---@field plugin? string Plugin that registered this binary
---@field callback? fun(success: boolean) Optional callback after install/update
---@field plugins string[] Plugins that registered this binary
---@field callbacks table<string, fun(success: boolean)> Callbacks keyed by plugin name
---@class GlazeAutoCheckConfig
---@field enabled? boolean Whether to auto-check for updates
@@ -147,11 +147,41 @@ end
---@param opts? { plugin?: string, callback?: fun(success: boolean) }
function M.register(name, url, opts)
opts = opts or {}
local plugin = opts.plugin or "unknown"
-- Check if this URL is already registered under a different name
for existing_name, binary in pairs(M._binaries) do
if binary.url == url and existing_name ~= name then
-- Same URL, different name - merge into existing entry
if not vim.tbl_contains(binary.plugins, plugin) then
table.insert(binary.plugins, plugin)
end
if opts.callback then
binary.callbacks[plugin] = opts.callback
end
return
end
end
-- Check if this name is already registered
local existing = M._binaries[name]
if existing then
-- Merge plugin into existing entry
if not vim.tbl_contains(existing.plugins, plugin) then
table.insert(existing.plugins, plugin)
end
if opts.callback then
existing.callbacks[plugin] = opts.callback
end
return
end
-- New binary registration
M._binaries[name] = {
name = name,
url = url,
plugin = opts.plugin,
callback = opts.callback,
plugins = opts.plugin and { opts.plugin } or {},
callbacks = opts.callback and { [plugin] = opts.callback } or {},
}
-- Auto-install if enabled and binary is missing

View File

@@ -93,10 +93,17 @@ local function run_task(task)
task.status = code == 0 and "done" or "error"
task.job_id = nil
-- Call binary callback if set
if task.binary.callback then
-- Refresh version info on success
if code == 0 then
require("glaze.checker").refresh_version(task.binary.name)
end
-- Call all registered callbacks
if task.binary.callbacks then
vim.schedule(function()
task.binary.callback(code == 0)
for _, cb in pairs(task.binary.callbacks) do
cb(code == 0)
end
end)
end

View File

@@ -323,8 +323,8 @@ function M._render_binary(text, binary, icons, update_info)
text:append(" " .. icon .. " ", icon_hl)
text:append(binary.name, "GlazeBinary")
if binary.plugin then
text:append(" (" .. binary.plugin .. ")", "GlazePlugin")
if binary.plugins and #binary.plugins > 0 then
text:append(" (" .. table.concat(binary.plugins, ", ") .. ")", "GlazePlugin")
end
-- Show update available indicator
@@ -353,9 +353,9 @@ function M._render_binary(text, binary, icons, update_info)
text:append(bin_path, "GlazeUrl"):nl()
end
if binary.plugin then
text:append("Plugin: ", "GlazeComment", { indent = 6 })
text:append(binary.plugin, "GlazePlugin"):nl()
if binary.plugins and #binary.plugins > 0 then
text:append("Plugins: ", "GlazeComment", { indent = 6 })
text:append(table.concat(binary.plugins, ", "), "GlazePlugin"):nl()
end
-- Show last error output from tasks