6.0 KiB
AGENTS.md
AI agent guide for working in glaze.nvim.
Project Overview
glaze.nvim is a Neovim plugin that provides centralized management for Go binaries used by other Neovim plugins. Think "Mason for Go binaries" with a lazy.nvim-style UI.
- Language: Lua (Neovim plugin)
- Requirements: Neovim >= 0.9, Go installed
- Author: Tai Groot (taigrr)
Directory Structure
lua/glaze/
├── init.lua # Main module: setup, config, registration API, binary path utilities
├── runner.lua # Task runner: parallel go install with concurrency control
├── checker.lua # Update checker: version comparison, auto-check scheduling
├── view.lua # UI: lazy.nvim-style floating window, keybinds, rendering
├── float.lua # Float window abstraction: backdrop, keymaps, resize handling
├── text.lua # Text rendering: buffered text with highlight segments
├── colors.lua # Highlight definitions: doughnut-inspired pink/magenta theme
├── health.lua # Health check: :checkhealth glaze
doc/
└── glaze.txt # Vim help documentation
Key Concepts
Binary Registration
Plugins register binaries via require("glaze").register(name, url, opts). Registration stores metadata in M._binaries table. Auto-install triggers if enabled and binary is missing.
Task Runner
runner.lua manages parallel go install jobs with configurable concurrency. Tasks have states: pending → running → done|error. The runner opens the UI automatically when tasks start.
Update Checking
checker.lua compares installed versions (go version -m) against latest (go list -m -json). State persisted to vim.fn.stdpath("data") .. "/glaze/state.json".
UI Architecture
float.lua: Generic floating window with backdrop (inspired by lazy.nvim)view.lua: Glaze-specific rendering, keybinds, spinner animationtext.lua: Buffered text builder with highlight segments and extmarks
Commands
| Command | Description |
|---|---|
:Glaze |
Open the UI |
:GlazeUpdate [name] |
Update all or specific binary |
:GlazeInstall [name] |
Install missing or specific binary |
:GlazeCheck |
Manual update check |
:checkhealth glaze |
Run health check |
Testing
No automated tests exist. Manual testing workflow:
-- In Neovim:
:luafile % -- Reload current file
:Glaze -- Test UI
:checkhealth glaze -- Verify setup
Test with actual binaries:
require("glaze").setup({})
require("glaze").register("glow", "github.com/charmbracelet/glow")
:GlazeInstall glow
Code Conventions
Module Pattern
All modules return a table M with public functions. Private functions prefixed with _:
local M = {}
M._private_state = {}
function M.public_fn() end
function M._private_fn() end
return M
Type Annotations
Uses LuaCATS (---@class, ---@param, ---@return) for type hints. LSP warnings about vim being undefined are expected (Neovim globals).
Async Patterns
vim.fn.jobstart()for external commandsvim.schedule()to defer to main loopvim.defer_fn()for delayed execution
UI Updates
- Runner notifies via
M._on_updatecallback - View subscribes and re-renders on notification
- Timer drives spinner animation (100ms interval)
Highlight Groups
All highlights prefixed with Glaze. Key groups:
GlazeH1,GlazeH2- HeadersGlazeBinary,GlazeUrl,GlazePlugin- ContentGlazeDone,GlazeError,GlazeRunning- StatusGlazeProgressDone,GlazeProgressTodo- Progress bar
Colors follow doughnut aesthetic (pink #FF6AD5 as primary accent).
Configuration
Default config in init.lua:53-78. Key options:
concurrency: Parallel jobs (default 4)auto_install.enabled: Install on registerauto_check.enabled/frequency: Update checkingauto_update.enabled: Auto-apply updates
Common Tasks
Adding a New Config Option
- Add to
GlazeConfigtype definition ininit.lua - Add default value in
M.config - Document in
README.mdanddoc/glaze.txt
Adding a New Command
- Create in
M.setup()viavim.api.nvim_create_user_command() - Document in README and help file
Modifying UI
- Edit
view.lua:render()for content changes - Edit
view.lua:open()to add keybinds - Edit
colors.luafor new highlight groups
Adding Health Checks
Add checks in health.lua:check() using vim.health.ok/warn/error/info.
Gotchas
-
vim global: All
vim.*calls show LSP warnings - this is normal for Neovim plugins without proper Lua LSP config. -
Race conditions:
runner.luarejects new tasks if already running. Checkrunner.is_running()first. -
Timer cleanup:
view.lua._timermust be stopped on close, or spinner keeps running. -
State file:
checker.luapersists to data dir. If corrupt, delete~/.local/share/nvim/glaze/state.json. -
GOBIN detection: Checks multiple locations:
$GOBIN,$GOPATH/bin,~/go/bin. Seeinit.lua:is_installed(). -
goenv support: Auto-detected in setup, changes
go_cmdto{ "goenv", "exec", "go" }.
API Reference
Main module (require("glaze")):
setup(opts)- Initialize with configregister(name, url, opts)- Register binaryunregister(name)- Remove binarybinaries()- Get all registeredis_installed(name)- Check if binary existsbin_path(name)- Get full pathstatus(name)- Get "installed"/"missing"/"unknown"
Runner (require("glaze.runner")):
update(names)/update_all()- Update binariesinstall(names)/install_missing()- Install binariesabort()- Stop all tasksis_running()/tasks()/stats()- Query state
Checker (require("glaze.checker")):
check(opts)- Check for updatesauto_check()- Check if interval passedget_update_info()- Get cached version info