mirror of https://github.com/folke/lazy.nvim.git
style: cleanup
This commit is contained in:
parent
a197f751f9
commit
a87b6e1005
|
@ -10,14 +10,22 @@ M.defaults = {
|
||||||
version = nil,
|
version = nil,
|
||||||
-- version = "*", -- enable this to try installing the latest stable versions of plugins
|
-- version = "*", -- enable this to try installing the latest stable versions of plugins
|
||||||
},
|
},
|
||||||
|
packpath = vim.fn.stdpath("data") .. "/site/pack/lazy", -- package path where new plugins will be installed
|
||||||
|
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
||||||
|
install_missing = true, -- install missing plugins on startup. This doesn't increase startup time.
|
||||||
|
git = {
|
||||||
|
-- defaults for `Lazy log`
|
||||||
|
-- log = { "-10" }, -- last 10 commits
|
||||||
|
log = { "--since=1 days ago" }, -- commits from the last 3 days
|
||||||
|
},
|
||||||
|
-- Any plugin spec that contains one of the patterns will use your
|
||||||
|
-- local repo in the projects folder instead of fetchig it from github
|
||||||
|
-- Mostly useful for plugin developers.
|
||||||
dev = {
|
dev = {
|
||||||
path = vim.fn.expand("~/projects"), -- the path where you store your projects
|
path = vim.fn.expand("~/projects"), -- the path where you store your projects
|
||||||
---@type string[]
|
---@type string[]
|
||||||
patterns = {}, -- For example {"folke"}
|
patterns = {}, -- For example {"folke"}
|
||||||
},
|
},
|
||||||
packpath = vim.fn.stdpath("data") .. "/site/pack/lazy",
|
|
||||||
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json",
|
|
||||||
view = {
|
|
||||||
ui = {
|
ui = {
|
||||||
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
|
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
|
||||||
border = "none",
|
border = "none",
|
||||||
|
@ -32,11 +40,6 @@ M.defaults = {
|
||||||
ft = " ",
|
ft = " ",
|
||||||
task = "✔ ",
|
task = "✔ ",
|
||||||
},
|
},
|
||||||
install_missing = true,
|
|
||||||
git = {
|
|
||||||
-- defaults for `Lazy log`
|
|
||||||
log = { "-10" }, -- last 10 commits
|
|
||||||
-- log = { "--since=3 days ago" }, -- commits from the last 3 days
|
|
||||||
throttle = 20, -- how frequently should the ui process render events
|
throttle = 20, -- how frequently should the ui process render events
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,7 @@ function M.autosave()
|
||||||
local hash = M.hash(cache_path)
|
local hash = M.hash(cache_path)
|
||||||
-- abort when the file was changed in the meantime
|
-- abort when the file was changed in the meantime
|
||||||
if hash == nil or M.eq(cache_hash, hash) then
|
if hash == nil or M.eq(cache_hash, hash) then
|
||||||
vim.fn.system("echo start >> foo.txt")
|
|
||||||
M.save_cache()
|
M.save_cache()
|
||||||
vim.fn.system("echo stop >> foo.txt")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -25,7 +25,7 @@ function M.setup(opts)
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
if not plugin._.installed then
|
if not plugin._.installed then
|
||||||
vim.cmd("do User LazyInstallPre")
|
vim.cmd("do User LazyInstallPre")
|
||||||
require("lazy.manage").install({ wait = true, show = Config.options.interactive })
|
require("lazy.manage").install({ wait = true })
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,17 +18,17 @@ end
|
||||||
|
|
||||||
M.commands = {
|
M.commands = {
|
||||||
clean = function(plugins)
|
clean = function(plugins)
|
||||||
Manage.clean({ clear = true, interactive = true, mode = "clean", plugins = plugins })
|
Manage.clean({ clear = true, mode = "clean", plugins = plugins })
|
||||||
end,
|
end,
|
||||||
clear = function()
|
clear = function()
|
||||||
Manage.clear()
|
Manage.clear()
|
||||||
View.show()
|
View.show()
|
||||||
end,
|
end,
|
||||||
install = function()
|
install = function()
|
||||||
Manage.install({ clear = true, interactive = true, mode = "install" })
|
Manage.install({ clear = true, mode = "install" })
|
||||||
end,
|
end,
|
||||||
log = function(plugins)
|
log = function(plugins)
|
||||||
Manage.log({ clear = true, interactive = true, mode = "log", plugins = plugins })
|
Manage.log({ clear = true, mode = "log", plugins = plugins })
|
||||||
end,
|
end,
|
||||||
show = function()
|
show = function()
|
||||||
View.show()
|
View.show()
|
||||||
|
@ -40,18 +40,18 @@ M.commands = {
|
||||||
View.show("profile")
|
View.show("profile")
|
||||||
end,
|
end,
|
||||||
sync = function()
|
sync = function()
|
||||||
Manage.clean({ interactive = true, clear = true, wait = true, mode = "sync" })
|
Manage.clean({ clear = true, wait = true, mode = "sync" })
|
||||||
Manage.update({ interactive = true })
|
Manage.update({ interactive = true })
|
||||||
Manage.install({ interactive = true })
|
Manage.install({ interactive = true })
|
||||||
end,
|
end,
|
||||||
update = function(plugins)
|
update = function(plugins)
|
||||||
Manage.update({ clear = true, interactive = true, mode = "update", plugins = plugins })
|
Manage.update({ clear = true, mode = "update", plugins = plugins })
|
||||||
end,
|
end,
|
||||||
check = function(plugins)
|
check = function(plugins)
|
||||||
Manage.check({ clear = true, interactive = true, mode = "check", plugins = plugins })
|
Manage.check({ clear = true, mode = "check", plugins = plugins })
|
||||||
end,
|
end,
|
||||||
restore = function(plugins)
|
restore = function(plugins)
|
||||||
Manage.update({ clear = true, interactive = true, lockfile = true, mode = "restore", plugins = plugins })
|
Manage.update({ clear = true, lockfile = true, mode = "restore", plugins = plugins })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ end)
|
||||||
|
|
||||||
describe("plugin spec opt", function()
|
describe("plugin spec opt", function()
|
||||||
it("handles dependencies", function()
|
it("handles dependencies", function()
|
||||||
Config.options.opt = false
|
Config.options.defaults.opt = false
|
||||||
local tests = {
|
local tests = {
|
||||||
{ "foo/bar", dependencies = { "foo/dep1", "foo/dep2" } },
|
{ "foo/bar", dependencies = { "foo/dep1", "foo/dep2" } },
|
||||||
{ "foo/bar", dependencies = { { "foo/dep1" }, "foo/dep2" } },
|
{ "foo/bar", dependencies = { { "foo/dep1" }, "foo/dep2" } },
|
||||||
|
@ -52,7 +52,7 @@ describe("plugin spec opt", function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("handles opt from dep", function()
|
it("handles opt from dep", function()
|
||||||
Config.options.opt = false
|
Config.options.defaults.opt = false
|
||||||
local spec = Plugin.Spec.new({ "foo/dep1", { "foo/bar", dependencies = { "foo/dep1", "foo/dep2" } } })
|
local spec = Plugin.Spec.new({ "foo/dep1", { "foo/bar", dependencies = { "foo/dep1", "foo/dep2" } } })
|
||||||
Config.plugins = spec.plugins
|
Config.plugins = spec.plugins
|
||||||
Plugin.update_state()
|
Plugin.update_state()
|
||||||
|
@ -65,8 +65,25 @@ describe("plugin spec opt", function()
|
||||||
assert(spec.plugins.dep1.opt == false)
|
assert(spec.plugins.dep1.opt == false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("handles defaults opt", function()
|
||||||
|
do
|
||||||
|
Config.options.defaults.opt = true
|
||||||
|
local spec = Plugin.Spec.new({ "foo/bar" })
|
||||||
|
Config.plugins = spec.plugins
|
||||||
|
Plugin.update_state()
|
||||||
|
assert(spec.plugins.bar.opt == true)
|
||||||
|
end
|
||||||
|
do
|
||||||
|
Config.options.defaults.opt = false
|
||||||
|
local spec = Plugin.Spec.new({ "foo/bar" })
|
||||||
|
Config.plugins = spec.plugins
|
||||||
|
Plugin.update_state()
|
||||||
|
assert(spec.plugins.bar.opt == false)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
it("handles opt from dep", function()
|
it("handles opt from dep", function()
|
||||||
Config.options.opt = false
|
Config.options.defaults.opt = false
|
||||||
local spec = Plugin.Spec.new({ "foo/bar", module = "foo" })
|
local spec = Plugin.Spec.new({ "foo/bar", module = "foo" })
|
||||||
Config.plugins = spec.plugins
|
Config.plugins = spec.plugins
|
||||||
Plugin.update_state()
|
Plugin.update_state()
|
||||||
|
|
Loading…
Reference in New Issue