mirror of
https://github.com/taigrr/glaze.nvim.git
synced 2026-04-02 03:09:10 -07:00
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:
@@ -128,6 +128,10 @@ require("glaze").setup({
|
|||||||
},
|
},
|
||||||
concurrency = 4, -- Max parallel installations
|
concurrency = 4, -- Max parallel installations
|
||||||
go_cmd = { "go" }, -- Auto-detects goenv if available
|
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 = {
|
auto_check = {
|
||||||
enabled = true, -- Auto-check for updates
|
enabled = true, -- Auto-check for updates
|
||||||
frequency = "daily", -- "daily", "weekly", or hours as number
|
frequency = "daily", -- "daily", "weekly", or hours as number
|
||||||
|
|||||||
@@ -151,6 +151,10 @@ Default configuration:
|
|||||||
},
|
},
|
||||||
concurrency = 4,
|
concurrency = 4,
|
||||||
go_cmd = { "go" }, -- Auto-detects goenv
|
go_cmd = { "go" }, -- Auto-detects goenv
|
||||||
|
auto_install = {
|
||||||
|
enabled = true, -- Auto-install missing binaries on register
|
||||||
|
silent = false, -- Suppress install notifications
|
||||||
|
},
|
||||||
auto_check = {
|
auto_check = {
|
||||||
enabled = true, -- Auto-check for updates on setup
|
enabled = true, -- Auto-check for updates on setup
|
||||||
frequency = "daily", -- "daily", "weekly", or hours (number)
|
frequency = "daily", -- "daily", "weekly", or hours (number)
|
||||||
|
|||||||
@@ -22,11 +22,16 @@ local M = {}
|
|||||||
---@field enabled boolean Whether to auto-check for updates
|
---@field enabled boolean Whether to auto-check for updates
|
||||||
---@field frequency string|number Frequency: "daily", "weekly", or hours as number
|
---@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
|
---@class GlazeConfig
|
||||||
---@field ui GlazeUIConfig
|
---@field ui GlazeUIConfig
|
||||||
---@field concurrency number Max parallel installations
|
---@field concurrency number Max parallel installations
|
||||||
---@field go_cmd string[] Go command (supports goenv)
|
---@field go_cmd string[] Go command (supports goenv)
|
||||||
---@field auto_check GlazeAutoCheckConfig
|
---@field auto_check GlazeAutoCheckConfig
|
||||||
|
---@field auto_install GlazeAutoInstallConfig
|
||||||
|
|
||||||
---@class GlazeUIConfig
|
---@class GlazeUIConfig
|
||||||
---@field border string Border style
|
---@field border string Border style
|
||||||
@@ -59,6 +64,10 @@ M.config = {
|
|||||||
enabled = true,
|
enabled = true,
|
||||||
frequency = "daily",
|
frequency = "daily",
|
||||||
},
|
},
|
||||||
|
auto_install = {
|
||||||
|
enabled = true,
|
||||||
|
silent = false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type table<string, GlazeBinary>
|
---@type table<string, GlazeBinary>
|
||||||
@@ -123,6 +132,7 @@ function M.setup(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Register a binary for management.
|
---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 name string Binary/executable name
|
||||||
---@param url string Go module URL (e.g., "github.com/charmbracelet/freeze")
|
---@param url string Go module URL (e.g., "github.com/charmbracelet/freeze")
|
||||||
---@param opts? { plugin?: string, callback?: fun(success: boolean) }
|
---@param opts? { plugin?: string, callback?: fun(success: boolean) }
|
||||||
@@ -134,6 +144,18 @@ function M.register(name, url, opts)
|
|||||||
plugin = opts.plugin,
|
plugin = opts.plugin,
|
||||||
callback = opts.callback,
|
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
|
end
|
||||||
|
|
||||||
---Unregister a binary.
|
---Unregister a binary.
|
||||||
|
|||||||
Reference in New Issue
Block a user