Compare commits

..

3 Commits

Author SHA1 Message Date
26ef7289f6 update readme 2025-07-01 23:34:32 -04:00
d406ee18f2 allow never syncing 2025-07-01 23:34:00 -04:00
e0f39fe0db allow disabling modules 2025-07-01 23:33:33 -04:00
3 changed files with 28 additions and 10 deletions

View File

@ -1,7 +1,5 @@
# dep
> This readme is a work in progress.
A versatile, declarative and correct [neovim][2] package manager in [Lua][3].
Originally written for personal use by [luaneko][4]. Adapted by [squibid][5] for
general use.
@ -11,13 +9,14 @@ What does that mean?
1. `versatile` - packages can be declared in any Lua file in any order of your
liking.
2. `declarative` - packages are declared using simple Lua tables.
3. `correct` - packages are always loaded in a correct and consistent order.
3. `correct` - packages are always loaded in a correct and consistent order
(barring any lazy loading).
In addition to the above dep has been built to be completely in control of you,
the user. With the help of lazy loading you can choose when your plugin loads
down to the finest detail (examples may be found below).
See also squibid's [neovim-configs][10] for an example of how dep can be used in
See also squibid's [neovim-config][10] for an example of how dep can be used in
practice.
## Requirements
@ -35,7 +34,7 @@ practice.
local path = vim.fn.stdpath("data") .. "/site/pack/deps/opt/dep"
if vim.fn.empty(vim.fn.glob(path)) > 0 then
vim.fn.system({ "git", "clone", "--depth=1", "https://git.squi.bid/dep", path })
vim.fn.system({ "git", "clone", "--depth=1", "https://git.squi.bid/squibid/dep", path })
end
vim.cmd("packadd dep")
@ -57,6 +56,7 @@ require "dep" {
- `:DepClean` - cleans removed packages.
- `:DepReload` - reloads all packages.
- `:DepLog` - opens the log file.
- `:DepUi` - opens the ui.
## Package specification
@ -83,8 +83,9 @@ A package must be declared in the following format.
os.execute(...)
end,
-- [function] Code used to determine when the package should be loaded.
-- [function|true] Code used to determine when the package should be loaded.
lazy = function(load)
load:cmd("LoadPackage")
end,
-- [string] Overrides the short name of the package.
@ -93,7 +94,7 @@ A package must be declared in the following format.
-- [string] Overrides the URL of the git repository to clone.
-- Defaults to "https://github.com/{full_name}.git".
url = "https://git.chiya.dev/user/package.git",
url = "https://git.squi.bid/user/package.git",
-- [string] Overrides the source in which the package is gotten
-- from. This is not set by default.
@ -351,7 +352,7 @@ require "dep" {
```
If you're in the need of a deeper understanding of how the utils work go check
out `lua/lazy/utils.lua` for the source code.
out `lua/lazy/loader/init.lua` for the source code.
## Separating code into modules
@ -378,6 +379,13 @@ return {
Package specifications from other modules can be loaded using the `modules` option.
```lua
require "dep" {
modules = {
prefix = "packages"
}
}
-- the above is equivalent to
require "dep" {
modules = {
prefix = "packages.",
@ -386,7 +394,7 @@ require "dep" {
}
}
-- the above is equivalent to
-- or
require "dep" {
modules = {
"packages.search",

View File

@ -62,7 +62,9 @@ end
---@param package package package table spec
---@return boolean sync
local function shouldsync(opts, package)
if opts.sync == "new" or opts.sync == nil then
if opts.sync == "never" then
return false
elseif opts.sync == "new" or opts.sync == nil then
return not package.exists
else
return opts.sync == "always"

View File

@ -5,6 +5,7 @@ local packager = require("dep.package")
---@class module
---@field name string name of the module
---@field desc string description of the module
---@field disable boolean weather to disable all the packages inside the module
---@field path string path to the module
---@field mod table the module
---@field packages package[] all packages registed from the module
@ -18,6 +19,8 @@ local module = {}
---@return module|false module false on failure to load module
---@nodiscard
function module:new(modpath, prefix, overrides)
overrides = overrides or {}
local ok, err
local o = {}
self = {}
@ -45,6 +48,11 @@ function module:new(modpath, prefix, overrides)
o.name = o.mod.name or o.name
o.desc = o.mod.desc or o.desc
-- ensure the overrides are properly set
overrides = vim.tbl_extend("force", overrides, {
disable = o.mod.disable or overrides.disable
})
-- allow a module to be a spec
if spec_man.check(o.mod, true) ~= false then
o.mod = { o.mod }