This document covers the Lua API for programmatic access to leanpack.nvim.
Initialize leanpack.nvim with configuration.
Parameters:
opts(table): Configuration options
Returns: nil
require('leanpack').setup({
cmd_prefix = 'leanpack',
defaults = { confirm = true },
})All plugin management operations are available as :Leanpack commands (not Lua API functions):
:Leanpack update " Update all plugins
:Leanpack update plugin-name " Update specific plugin
:Leanpack clean " Remove unused plugins
:Leanpack sync " Update + clean
:Leanpack build! " Run all build hooks
:Leanpack load! " Load all pending pluginsSee Commands for full details.
Get all plugin entries.
Returns: table of plugin entries
local entries = require('leanpack.state').get_all_entries()
for src, entry in pairs(entries) do
print(src, entry.load_status)
endGet specific plugin entry.
Parameters:
src(string): Plugin source
Returns: table or nil
local entry = require('leanpack.state').get_entry('nvim-treesitter/nvim-treesitter')Check if leanpack is configured.
Returns: boolean
if require('leanpack.state').is_configured() then
-- leanpack is ready
endNormalize a plugin spec.
Parameters:
spec(table): Plugin specification
Returns: table normalized spec
local normalized = require('leanpack.spec').normalize_spec({
'user/repo',
opts = {},
})Plugins can define hooks in their specs:
Runs before plugin loads.
return {
'user/repo',
init = function(plugin)
vim.g.plugin_loaded = true
end,
}Runs after plugin loads.
return {
'user/repo',
config = function(plugin, opts)
require('plugin').setup(opts)
end,
}Runs on install/update.
return {
'user/repo',
build = function(plugin)
vim.fn.system({ 'make', '-C', plugin.path })
end,
}---@class leanpack.Plugin
---@field name string Plugin name
---@field path string Plugin directory path
---@field spec vim.pack.Spec The vim.pack spec---@class leanpack.Spec
---@field [1] string Short name (user/repo)
---@field src? string Source URL or path
---@field dir? string Local directory
---@field url? string Git URL
---@field name? string Custom name
---@field dependencies? string|string[]|table Dependencies
---@field optional? boolean Optional dependency
---@field enabled? boolean|function Enable/disable
---@field cond? boolean|function Conditional loading
---@field lazy? boolean Force lazy loading
---@field priority? number Load priority
---@field dev? boolean Dev mode
---@field opts? table Setup options
---@field init? function Init hook
---@field config? function|boolean Config hook
---@field build? string|function Build hook
---@field event? string|string[]|table Event trigger
---@field cmd? string|string[] Command trigger
---@field keys? string|table|table[] Keymap trigger
---@field ft? string|string[] Filetype trigger
---@field version? string Version
---@field sem_version? string Semver (lazy.nvim compat)
---@field branch? string Branch
---@field tag? string Tag
---@field commit? string Commit
---@field main? string Main module- Commands - CLI reference
- Troubleshooting - Common issues