Compare commits
3 Commits
e8276e3137
...
26ef7289f6
Author | SHA1 | Date | |
---|---|---|---|
26ef7289f6
|
|||
d406ee18f2
|
|||
e0f39fe0db
|
26
README.md
26
README.md
@ -1,7 +1,5 @@
|
|||||||
# dep
|
# dep
|
||||||
|
|
||||||
> This readme is a work in progress.
|
|
||||||
|
|
||||||
A versatile, declarative and correct [neovim][2] package manager in [Lua][3].
|
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
|
Originally written for personal use by [luaneko][4]. Adapted by [squibid][5] for
|
||||||
general use.
|
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
|
1. `versatile` - packages can be declared in any Lua file in any order of your
|
||||||
liking.
|
liking.
|
||||||
2. `declarative` - packages are declared using simple Lua tables.
|
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,
|
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
|
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).
|
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.
|
practice.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
@ -35,7 +34,7 @@ practice.
|
|||||||
local path = vim.fn.stdpath("data") .. "/site/pack/deps/opt/dep"
|
local path = vim.fn.stdpath("data") .. "/site/pack/deps/opt/dep"
|
||||||
|
|
||||||
if vim.fn.empty(vim.fn.glob(path)) > 0 then
|
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
|
end
|
||||||
|
|
||||||
vim.cmd("packadd dep")
|
vim.cmd("packadd dep")
|
||||||
@ -57,6 +56,7 @@ require "dep" {
|
|||||||
- `:DepClean` - cleans removed packages.
|
- `:DepClean` - cleans removed packages.
|
||||||
- `:DepReload` - reloads all packages.
|
- `:DepReload` - reloads all packages.
|
||||||
- `:DepLog` - opens the log file.
|
- `:DepLog` - opens the log file.
|
||||||
|
- `:DepUi` - opens the ui.
|
||||||
|
|
||||||
## Package specification
|
## Package specification
|
||||||
|
|
||||||
@ -83,8 +83,9 @@ A package must be declared in the following format.
|
|||||||
os.execute(...)
|
os.execute(...)
|
||||||
end,
|
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)
|
lazy = function(load)
|
||||||
|
load:cmd("LoadPackage")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- [string] Overrides the short name of the package.
|
-- [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.
|
-- [string] Overrides the URL of the git repository to clone.
|
||||||
-- Defaults to "https://github.com/{full_name}.git".
|
-- 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
|
-- [string] Overrides the source in which the package is gotten
|
||||||
-- from. This is not set by default.
|
-- 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
|
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
|
## Separating code into modules
|
||||||
|
|
||||||
@ -378,6 +379,13 @@ return {
|
|||||||
Package specifications from other modules can be loaded using the `modules` option.
|
Package specifications from other modules can be loaded using the `modules` option.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
require "dep" {
|
||||||
|
modules = {
|
||||||
|
prefix = "packages"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- the above is equivalent to
|
||||||
require "dep" {
|
require "dep" {
|
||||||
modules = {
|
modules = {
|
||||||
prefix = "packages.",
|
prefix = "packages.",
|
||||||
@ -386,7 +394,7 @@ require "dep" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- the above is equivalent to
|
-- or
|
||||||
require "dep" {
|
require "dep" {
|
||||||
modules = {
|
modules = {
|
||||||
"packages.search",
|
"packages.search",
|
||||||
|
@ -62,7 +62,9 @@ end
|
|||||||
---@param package package package table spec
|
---@param package package package table spec
|
||||||
---@return boolean sync
|
---@return boolean sync
|
||||||
local function shouldsync(opts, package)
|
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
|
return not package.exists
|
||||||
else
|
else
|
||||||
return opts.sync == "always"
|
return opts.sync == "always"
|
||||||
|
@ -5,6 +5,7 @@ local packager = require("dep.package")
|
|||||||
---@class module
|
---@class module
|
||||||
---@field name string name of the module
|
---@field name string name of the module
|
||||||
---@field desc string description 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 path string path to the module
|
||||||
---@field mod table the module
|
---@field mod table the module
|
||||||
---@field packages package[] all packages registed from 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
|
---@return module|false module false on failure to load module
|
||||||
---@nodiscard
|
---@nodiscard
|
||||||
function module:new(modpath, prefix, overrides)
|
function module:new(modpath, prefix, overrides)
|
||||||
|
overrides = overrides or {}
|
||||||
|
|
||||||
local ok, err
|
local ok, err
|
||||||
local o = {}
|
local o = {}
|
||||||
self = {}
|
self = {}
|
||||||
@ -45,6 +48,11 @@ function module:new(modpath, prefix, overrides)
|
|||||||
o.name = o.mod.name or o.name
|
o.name = o.mod.name or o.name
|
||||||
o.desc = o.mod.desc or o.desc
|
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
|
-- allow a module to be a spec
|
||||||
if spec_man.check(o.mod, true) ~= false then
|
if spec_man.check(o.mod, true) ~= false then
|
||||||
o.mod = { o.mod }
|
o.mod = { o.mod }
|
||||||
|
Reference in New Issue
Block a user