From 7ab9da9c568456f6edf899e84d488c70e310f351 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Thu, 19 Feb 2026 03:24:40 +0000 Subject: [PATCH] feat: add auto_update config, clarify auto_install vs auto_update vs auto_check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - auto_install (default: true) — install missing binaries on register - auto_check (default: true) — check for available updates periodically - auto_update (default: false) — auto-update when newer versions found - Disabling auto_check also disables auto_update - Updated README and help docs --- README.md | 5 ++++- doc/glaze.txt | 5 ++++- lua/glaze/checker.lua | 18 +++++++++++++++--- lua/glaze/init.lua | 15 +++++++++++---- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b815910..d159dd2 100644 --- a/README.md +++ b/README.md @@ -133,9 +133,12 @@ require("glaze").setup({ silent = false, -- Suppress install notifications }, auto_check = { - enabled = true, -- Auto-check for updates + enabled = true, -- Auto-check for updates (disabling also disables auto_update) frequency = "daily", -- "daily", "weekly", or hours as number }, + auto_update = { + enabled = false, -- Auto-update binaries when newer versions are found (requires auto_check) + }, }) ``` diff --git a/doc/glaze.txt b/doc/glaze.txt index 907ac2d..f97fa03 100644 --- a/doc/glaze.txt +++ b/doc/glaze.txt @@ -156,9 +156,12 @@ Default configuration: silent = false, -- Suppress install notifications }, auto_check = { - enabled = true, -- Auto-check for updates on setup + enabled = true, -- Auto-check for updates (disabling also disables auto_update) frequency = "daily", -- "daily", "weekly", or hours (number) }, + auto_update = { + enabled = false, -- Auto-update when newer versions found (requires auto_check) + }, }) < diff --git a/lua/glaze/checker.lua b/lua/glaze/checker.lua index 20390a5..a20806a 100644 --- a/lua/glaze/checker.lua +++ b/lua/glaze/checker.lua @@ -201,10 +201,22 @@ function M.check(opts) end write_state(state) - if not opts.silent then + -- Auto-update if enabled (requires auto_check to be enabled) + if updates_found > 0 and glaze.config.auto_update.enabled and glaze.config.auto_check.enabled then + vim.schedule(function() + local to_update = {} + for n, i in pairs(M._update_info) do + if i.has_update then + table.insert(to_update, n) + end + end + vim.notify("Glaze: auto-updating " .. #to_update .. " binary(ies)…", vim.log.levels.INFO) + require("glaze.runner").update(to_update) + end) + elseif not opts.silent then if updates_found > 0 then vim.schedule(function() - vim.notify("Glaze: " .. updates_found .. " update(s) available", vim.log.levels.INFO) + vim.notify("Glaze: " .. updates_found .. " update(s) available — run :GlazeUpdate", vim.log.levels.INFO) end) else vim.schedule(function() @@ -213,7 +225,7 @@ function M.check(opts) end elseif updates_found > 0 then vim.schedule(function() - vim.notify("Glaze: " .. updates_found .. " update(s) available", vim.log.levels.INFO) + vim.notify("Glaze: " .. updates_found .. " update(s) available — run :GlazeUpdate", vim.log.levels.INFO) end) end diff --git a/lua/glaze/init.lua b/lua/glaze/init.lua index a2b433f..6f1d14b 100644 --- a/lua/glaze/init.lua +++ b/lua/glaze/init.lua @@ -26,12 +26,16 @@ local M = {} ---@field enabled boolean Whether to auto-install missing binaries on register ---@field silent boolean Suppress notifications during auto-install +---@class GlazeAutoUpdateConfig +---@field enabled boolean Whether to auto-update binaries when newer versions are found (requires auto_check) + ---@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 +---@field auto_check GlazeAutoCheckConfig +---@field auto_update GlazeAutoUpdateConfig ---@class GlazeUIConfig ---@field border string Border style @@ -60,13 +64,16 @@ M.config = { }, concurrency = 4, go_cmd = { "go" }, + auto_install = { + enabled = true, + silent = false, + }, auto_check = { enabled = true, frequency = "daily", }, - auto_install = { - enabled = true, - silent = false, + auto_update = { + enabled = false, }, }