Modular package, package's installation and configuration in same file, decoupling package manager
require('pack-config').setup {
-- must
scan_paths = { '/path/pre', '/path/subpath', '/path/after' },
-- optional
-- default to select from the order list [packer.nvim, paq-nvim, lazy.nvim] if exists
loader = require('pack-config.loader.packer'),
-- optional
loader_opts = {},
-- optional
-- default to select from the order list [uv, fd] if exists
-- uv: which use vim.loop.fs_scandir
-- fd: which use the cli fd
scanner = require('pack-config.scanner.uv'),
-- optional
-- default for uv: https://github.com/someoneonsmile/pack-config.nvim/blob/main/lua/pack-config/scanner/uv.lua#L3C1-L8C2
scanner_opts = {},
-- optional, default
parser = require('pack-config.parser.lua'),
-- optional
parser_opts = {},
-- optional, env for all pack file
env = {
-- default, for get other pack
pack = function(pack_name)
...
end
},
-- optional, provide convenience for debug, bisect
block_list = {
'[pack_name_a]',
'[pack_name_b]',
-- '[pack_name_c]',
},
}
detail
-- pack config
local M = {}
-- must
M.name = '[pack_name]'
-- optional
-- subs will eventually be merged into the main pack,
-- similar to the conf.d directory.
-- subs support multi-level nesting.
M.subs = {
require('somepath'),
{
resources = {
-- resource
{
'[resource_url]',
as = '',
branch = '',
tag = '',
commit = '',
-- lock, skip updating this plugin
pin = false,
-- manually marks a plugin as optional
opt = true,
-- update / install hook
run = function() end,
rely = {
-- nested resource
{'[other_resource_url]', rely = {}}
},
}
}
setup = function() end,
config = function() end,
-- lazy = true
-- lazy also support function that return boolean
lazy = function()
return true
end
-- subs = ...
},
}
-- optional
-- format: string, table or function
M.resources = function()
return {
-- resource
{
'[resource_url]',
as = '',
branch = '',
tag = '',
commit = '',
-- lock, skip updating this plugin
pin = false,
-- manually marks a plugin as optional
opt = true,
-- update / install hook
run = function() end,
rely = {
-- nested resource
{'[other_resource_url]', rely = {}}
},
},
-- optional, placing deprecated resources
-- when 'deprecated_resource' use by other pack, will log the deprecated and replace_with tip
deprecated = {
{ '[deprecated_resource]', replace_with = '[new_resource]'}
}
}
end
-- optional
-- format: string, table or function
M.after = { '[other_pack_name]' }
-- optional
-- pack setup
M.setup = function()
-- use pack the env fn to load other pack
local other_pack = pack('other_pack_name')
...
end
-- optional
-- config run after all pack's setup
M.config = function()
-- use pack fn to load other pack
local other_pack = pack('other_pack_name')
...
end
-- lazy = true
-- lazy also support function that return boolean
lazy = function()
return true
end
return M
variants
- string
M.resources = 'resource_url'
- table
M.resources = { 'resource_url_a', 'resource_url_b'}
- full table
M.resources = {
{
'[resource_url_a]',
as = '',
branch = '',
tag = '',
commit = '',
pin = false,
opt = false,
run = function() end,
rely = {
-- nested resource
{'[other_resource_url]', rely = {}}
},
},
{
'[resource_url_b]',
as = '',
branch = '',
tag = '',
commit = '',
pin = false,
opt = true,
run = function() end,
rely = {
-- nested resource
{'[other_resource_url]', rely = {}}
},
},
-- optional, placing deprecated resources
-- when use by other pack, will log the deprecated tip
deprecated = {
{ '[deprecated_resource_a]', replace_with = '[new_resource_a]'}
{ '[deprecated_resource_b]', replace_with = '[new_resource_b]'}
}
}
- function
M.resources = function()
return 'all_kind_above'
end
variants
- string
M.after = 'other_pack_name'
- table
M.after = { 'other_pack_name_a', 'other_pack_name_b' }
- function
M.after = function()
return 'all_kind_above'
end
vim.fn.stdpath('data') .. '/site/pack/init/start'
: predownload pack loader location
vim.fn.stdpath('data') .. '/site/pack/packer/start'
: pack loader download location
:lua require('pack-config.profile').report()
detail
to get the pack file
Format
local M = {}
M.exist = bool or function return bool
-- optional
M.init = function(opts) end
-- scan the paths return the pack_files
M.scan = function(paths)
end
to parse the pack file
Format
local M = {}
M.exist = bool or function return bool
-- optional
M.init = function(opts) end
M.is_pack = function(pack) return true end
-- parse the pack file to the format
M.parse = function(pack)
return {
name = '',
resources = string, table or function,
after = string, table or function,
setup = function() end
config = function() end
}
end
use package manager to load the pack
Format
local M = {}
M.exist = bool or function return bool
-- optional
M.init = function(opts) end
-- parse the pack file to the format
M.load = function(packs)
end
PackProfileReport
: report the pack profile data
example
index | group | item | time |
---|---|---|---|
1 | setup-config | lsp::setup | 13.42 |
2 | setup-config | telescope::setup | 12.60 |
3 | setup-config | theme::config | 11.64 |
4 | setup-config | complete::setup | 11.23 |
5 | setup-config | statusline::setup | 10.15 |
- lua check and style
- pack loader add init function
- deprecate tip
- context muti instance
- external lua file support
- topologic sort
- circle check
- pack name repeat error
- refact log file (level with endpoin)
- log use vim.notify
- setfenv with setup and config
- split parser
- profile
- error handler
- parallel