feat: add auto-install for missing binaries on register

- New config: auto_install.enabled (default true) and auto_install.silent
- When a plugin registers a binary via glaze.register() and it's missing,
  glaze automatically installs it in the background
- Can be disabled with auto_install = { enabled = false }
- Updated README and help docs
This commit is contained in:
2026-02-19 03:23:15 +00:00
parent 6927b0b914
commit c905edc162
3 changed files with 30 additions and 0 deletions

View File

@@ -22,11 +22,16 @@ local M = {}
---@field enabled boolean Whether to auto-check for updates
---@field frequency string|number Frequency: "daily", "weekly", or hours as number
---@class GlazeAutoInstallConfig
---@field enabled boolean Whether to auto-install missing binaries on register
---@field silent boolean Suppress notifications during auto-install
---@class GlazeConfig
---@field ui GlazeUIConfig
---@field concurrency number Max parallel installations
---@field go_cmd string[] Go command (supports goenv)
---@field auto_check GlazeAutoCheckConfig
---@field auto_install GlazeAutoInstallConfig
---@class GlazeUIConfig
---@field border string Border style
@@ -59,6 +64,10 @@ M.config = {
enabled = true,
frequency = "daily",
},
auto_install = {
enabled = true,
silent = false,
},
}
---@type table<string, GlazeBinary>
@@ -123,6 +132,7 @@ function M.setup(opts)
end
---Register a binary for management.
---If auto_install is enabled and the binary is missing, it will be installed automatically.
---@param name string Binary/executable name
---@param url string Go module URL (e.g., "github.com/charmbracelet/freeze")
---@param opts? { plugin?: string, callback?: fun(success: boolean) }
@@ -134,6 +144,18 @@ function M.register(name, url, opts)
plugin = opts.plugin,
callback = opts.callback,
}
-- Auto-install if enabled and binary is missing
if M.config.auto_install.enabled and not M.is_installed(name) then
vim.defer_fn(function()
if not M.is_installed(name) then
if not M.config.auto_install.silent then
vim.notify("[glaze] Auto-installing " .. name .. "", vim.log.levels.INFO)
end
require("glaze.runner").install({ name })
end
end, 100)
end
end
---Unregister a binary.