From c905edc162b4e8674739aaa8c951e3792db1e465 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Thu, 19 Feb 2026 03:23:15 +0000 Subject: [PATCH] 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 --- README.md | 4 ++++ doc/glaze.txt | 4 ++++ lua/glaze/init.lua | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/README.md b/README.md index 1d7c65b..b815910 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,10 @@ require("glaze").setup({ }, concurrency = 4, -- Max parallel installations go_cmd = { "go" }, -- Auto-detects goenv if available + auto_install = { + enabled = true, -- Auto-install missing binaries on register + silent = false, -- Suppress install notifications + }, auto_check = { enabled = true, -- Auto-check for updates frequency = "daily", -- "daily", "weekly", or hours as number diff --git a/doc/glaze.txt b/doc/glaze.txt index 27e3a29..907ac2d 100644 --- a/doc/glaze.txt +++ b/doc/glaze.txt @@ -151,6 +151,10 @@ Default configuration: }, concurrency = 4, go_cmd = { "go" }, -- Auto-detects goenv + auto_install = { + enabled = true, -- Auto-install missing binaries on register + silent = false, -- Suppress install notifications + }, auto_check = { enabled = true, -- Auto-check for updates on setup frequency = "daily", -- "daily", "weekly", or hours (number) diff --git a/lua/glaze/init.lua b/lua/glaze/init.lua index c45ed00..a2b433f 100644 --- a/lua/glaze/init.lua +++ b/lua/glaze/init.lua @@ -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 @@ -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.