From 3bde7b5ba8b99941b314a75d8650a0a6c8552144 Mon Sep 17 00:00:00 2001
From: Tsakiris Tryfon
Date: Wed, 4 Jan 2023 15:02:48 +0200
Subject: [PATCH 001/992] fix(keys): Use vim's default value for an unset
g:mapleader (#316)
---
lua/lazy/core/handler/keys.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index c6ebdde..dd55cef 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -15,7 +15,7 @@ local M = {}
---@param feed string
function M.replace_special(feed)
- for special, key in pairs({ leader = vim.g.mapleader, localleader = vim.g.maplocalleader }) do
+ for special, key in pairs({ leader = vim.g.mapleader or "\\", localleader = vim.g.maplocalleader or "\\" }) do
local pattern = "<"
for i = 1, #special do
pattern = pattern .. "[" .. special:sub(i, i) .. special:upper():sub(i, i) .. "]"
From dea43afc4adff21a6d5864a378459a140a702c0c Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 4 Jan 2023 17:50:57 +0100
Subject: [PATCH 002/992] feat(spec): allow import property on a plugin spec
---
lua/lazy/core/plugin.lua | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index cddeefc..e9af209 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -45,7 +45,10 @@ function Spec:add(plugin, results, is_dep)
-- check if we already processed this spec. Can happen when a user uses the same instance of a spec in multiple specs
-- see https://github.com/folke/lazy.nvim/issues/45
if plugin._ then
- return results and table.insert(results, plugin.name)
+ if results then
+ table.insert(results, plugin.name)
+ end
+ return plugin
end
if not plugin.url and plugin[1] then
@@ -76,6 +79,7 @@ function Spec:add(plugin, results, is_dep)
end
else
self:error("Invalid plugin spec " .. vim.inspect(plugin))
+ return
end
plugin.event = type(plugin.event) == "string" and { plugin.event } or plugin.event
@@ -91,7 +95,10 @@ function Spec:add(plugin, results, is_dep)
plugin = self:merge(self.plugins[plugin.name], plugin)
end
self.plugins[plugin.name] = plugin
- return results and table.insert(results, plugin.name)
+ if results then
+ table.insert(results, plugin.name)
+ end
+ return plugin
end
function Spec:error(msg)
@@ -182,12 +189,19 @@ function Spec:normalize(spec, results, is_dep)
for _, s in ipairs(spec) do
self:normalize(s, results, is_dep)
end
+ elseif spec[1] or spec.dir or spec.url then
+ ---@cast spec LazyPlugin
+ local plugin = self:add(spec, results, is_dep)
+ ---@diagnostic disable-next-line: cast-type-mismatch
+ ---@cast plugin LazySpecImport
+ if plugin and plugin.import then
+ self:import(plugin)
+ end
elseif spec.import then
---@cast spec LazySpecImport
self:import(spec)
else
- ---@cast spec LazyPlugin
- self:add(spec, results, is_dep)
+ self:error("Invalid plugin spec " .. vim.inspect(spec))
end
return results
end
From 886a91c688c57b59f86945127f5822db8f49cf8e Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 4 Jan 2023 20:23:36 +0100
Subject: [PATCH 003/992] ci: new templates
---
.github/ISSUE_TEMPLATE/bug_report.yml | 15 ++++-----------
.github/ISSUE_TEMPLATE/feature_request.yml | 2 +-
.github/workflows/ci.yml | 8 ++------
3 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index e6b2b68..c7a92d3 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -12,11 +12,11 @@ body:
label: Did you check docs and existing issues?
description: Make sure you checked all of the below before submitting an issue
options:
- - label: I have read all the lazy docs
+ - label: I have read all the lazy.nvim docs
required: true
- - label: I have searched the existing issues of lazy
+ - label: I have searched the existing issues of lazy.nvim
required: true
- - label: I have searched the exsiting issues of the plugin I have a problem with
+ - label: I have searched the exsiting issues of plugins related to this issue
required: true
- type: input
attributes:
@@ -68,14 +68,7 @@ body:
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
- vim.fn.system({
- "git",
- "clone",
- "--filter=blob:none",
- "--single-branch",
- "https://github.com/folke/lazy.nvim.git",
- lazypath,
- })
+ vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
index ad7f1a1..7a10d84 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -8,7 +8,7 @@ body:
label: Did you check the docs?
description: Make sure you read all the docs before submitting a feature request
options:
- - label: I have read all the lazy docs
+ - label: I have read all the lazy.nvim docs
required: true
- type: textarea
validations:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0012797..2adb58f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,17 +15,13 @@ jobs:
- name: Install Neovim
shell: bash
run: |
- if [ "$RUNNER_OS" == "Linux" ]; then
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.deb -O /tmp/nvim.deb
sudo dpkg -i /tmp/nvim.deb
- else
- choco install neovim --pre
- echo "C:/tools/neovim/nvim-win64/bin" >> $GITHUB_PATH
- fi
- name: Run Tests
run: |
nvim --version
- nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests// {minimal_init = 'tests//init.lua', sequential = true}"
+ [ ! -d tests ] && exit 0
+ nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
docs:
runs-on: ubuntu-latest
needs: tests
From 457f0bb7cec1e86ab58b9895f9c2cc3088a724d1 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 4 Jan 2023 22:50:23 +0100
Subject: [PATCH 004/992] chore(main): release 7.12.0 (#317)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 191ee02..9eac654 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,17 @@
# Changelog
+## [7.12.0](https://github.com/folke/lazy.nvim/compare/v7.11.0...v7.12.0) (2023-01-04)
+
+
+### Features
+
+* **spec:** allow import property on a plugin spec ([dea43af](https://github.com/folke/lazy.nvim/commit/dea43afc4adff21a6d5864a378459a140a702c0c))
+
+
+### Bug Fixes
+
+* **keys:** Use vim's default value for an unset g:mapleader ([#316](https://github.com/folke/lazy.nvim/issues/316)) ([3bde7b5](https://github.com/folke/lazy.nvim/commit/3bde7b5ba8b99941b314a75d8650a0a6c8552144))
+
## [7.11.0](https://github.com/folke/lazy.nvim/compare/v7.10.0...v7.11.0) (2023-01-04)
From c59c05c7a80693fda369ccab572f8eaca50a1b4f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 4 Jan 2023 23:16:55 +0100
Subject: [PATCH 005/992] fix(loader): run plugin config before sourcing
runtime
---
.gitignore | 2 ++
lua/lazy/core/loader.lua | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index e62ab00..cc5457a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,5 @@ doc/tags
debug
.repro
foo.*
+*.log
+data
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index c2bc844..aaffe94 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -217,10 +217,10 @@ function M._load(plugin, reason)
end, "Failed to load deps for " .. plugin.name)
end
- M.packadd(plugin.dir)
if plugin.config then
M.config(plugin)
end
+ M.packadd(plugin.dir)
plugin._.loaded.time = Util.track().time
table.remove(M.loading)
From 847ef091fa65e09cb682be0736b2b7d6a5d1649d Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 5 Jan 2023 11:30:47 +0100
Subject: [PATCH 006/992] style: disabled stats debug
---
lua/lazy/core/cache.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index e67b1af..b63cc87 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -107,7 +107,7 @@ function M.disable()
if M.debug and vim.tbl_count(M.topmods) > 1 then
M.log(M.topmods, vim.log.levels.WARN, { title = "topmods" })
end
- if M.debug then
+ if M.debug and false then
local stats = vim.deepcopy(M.stats)
stats.time = (stats.time or 0) / 1e6
stats.find.time = (stats.find.time or 0) / 1e6
From e4f79a42d650c926ea12edb7dbe2efbe1031b723 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 5 Jan 2023 11:31:13 +0100
Subject: [PATCH 007/992] fix(util): Util.try can now work without an error
message
---
lua/lazy/core/util.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 6724088..48582c0 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -92,7 +92,7 @@ function M.try(fn, opts)
end
level = level + 1
end
- msg = msg .. "\n\n" .. err
+ msg = (msg and (msg .. "\n\n") or "") .. err
if #trace > 0 then
msg = msg .. "\n\n# stacktrace:\n" .. table.concat(trace, "\n")
end
From af351f69ba94b526eecf6488e0d6c86eb6875e65 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 5 Jan 2023 10:31:58 +0000
Subject: [PATCH 008/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index fcef79c..f0599b9 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 04
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 05
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From b2dec14824383137440040da0d9d107f3a29c656 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 5 Jan 2023 13:42:17 +0100
Subject: [PATCH 009/992] fix(cache): check full paths of cached modpaths.
Fixes #324
---
lua/lazy/core/cache.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index b63cc87..edba74a 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -55,7 +55,7 @@ function M.check_path(modname, modpath)
-- check rtp excluding plugins. This is a very small list, so should be fast
for _, path in ipairs(M.get_rtp()) do
- if modpath:find(path, 1, true) == 1 then
+ if modpath:find(path .. "/", 1, true) == 1 then
return true
end
end
From aadc9126947923de074737795738714011d75b65 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 5 Jan 2023 14:28:28 +0100
Subject: [PATCH 010/992] docs: removed my dots in favor of LazyVim
---
README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 65d5631..85020ab 100644
--- a/README.md
+++ b/README.md
@@ -657,12 +657,12 @@ return {
- any lua file in `~/.config/nvim/lua/plugins/*.lua` will be automatically merged in the main plugin spec
-For a real-life example, you can check my personal dots:
+For a real-life example, you can check [LazyVim](https://github.com/folke/LazyVim),
+a starter template for lazy Neovim users.
-- [init.lua](https://github.com/folke/dot/blob/master/config/nvim/init.lua) where I require `config.lazy`
-- [config.lazy](https://github.com/folke/dot/blob/master/config/nvim/lua/config/lazy.lua) where I bootstrap and setup **lazy.nvim**
-- [config.plugins](https://github.com/folke/dot/blob/master/config/nvim/lua/plugins/init.lua) is my main plugin config module
-- Any submodule of [config.plugins (submodules)](https://github.com/folke/dot/tree/master/config/nvim/lua/plugins) will be automatically loaded as well.
+- [init.lua](https://github.com/folke/LazyVim/blob/main/init.lua) where `lazyvim.config.lazy` is required
+- [lazyvim.config.lazy](https://github.com/folke/LazyVim/blob/main/lua/lazyvim/config/lazy.lua) where we setup **lazy.nvim**
+- [lazyvim.plugins](https://github.com/folke/LazyVim/tree/main/lua/lazyvim/plugins) contains all the plugin specs that will be loaded
## 📦 Migration Guide
From caf3897841ec870db66e7785c32c93a22a54bacf Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 5 Jan 2023 13:29:20 +0000
Subject: [PATCH 011/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index f0599b9..9f8d335 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -718,13 +718,13 @@ Example:
- any lua file in `~/.config/nvim/lua/plugins/.lua` will be automatically merged in the main plugin spec
-For a real-life example, you can check my personal dots:
+For a real-life example, you can check LazyVim
+, a starter template for lazy Neovim users.
-- init.lua where I require `config.lazy`
-- config.lazy where I bootstrap and setup **lazy.nvim**
-- config.plugins is my main plugin config module
-- Any submodule of config.plugins (submodules) will be automatically loaded as well.
+- init.lua where `lazyvim.config.lazy` is required
+- lazyvim.config.lazy where we setup **lazy.nvim**
+- lazyvim.plugins contains all the plugin specs that will be loaded
MIGRATION GUIDE *lazy.nvim-migration-guide*
From d3b0d3e851b5609a2630e0307e18dc852efd0bd0 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 5 Jan 2023 14:32:13 +0100
Subject: [PATCH 012/992] chore(main): release 7.12.1 (#321)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9eac654..76760e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog
+## [7.12.1](https://github.com/folke/lazy.nvim/compare/v7.12.0...v7.12.1) (2023-01-05)
+
+
+### Bug Fixes
+
+* **cache:** check full paths of cached modpaths. Fixes [#324](https://github.com/folke/lazy.nvim/issues/324) ([b2dec14](https://github.com/folke/lazy.nvim/commit/b2dec14824383137440040da0d9d107f3a29c656))
+* **loader:** run plugin config before sourcing runtime ([c59c05c](https://github.com/folke/lazy.nvim/commit/c59c05c7a80693fda369ccab572f8eaca50a1b4f))
+* **util:** Util.try can now work without an error message ([e4f79a4](https://github.com/folke/lazy.nvim/commit/e4f79a42d650c926ea12edb7dbe2efbe1031b723))
+
## [7.12.0](https://github.com/folke/lazy.nvim/compare/v7.11.0...v7.12.0) (2023-01-04)
From 13af39b83ebbe632b265d5b84c3a0225022d4359 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 5 Jan 2023 16:52:02 +0100
Subject: [PATCH 013/992] refactor: easier to pass window options for floats
---
lua/lazy/util.lua | 23 ++++++++----
lua/lazy/view/float.lua | 80 ++++++++++++++++++++--------------------
lua/lazy/view/init.lua | 6 ++-
lua/lazy/view/render.lua | 2 +-
4 files changed, 62 insertions(+), 49 deletions(-)
diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua
index 793e832..d1b4257 100644
--- a/lua/lazy/util.lua
+++ b/lua/lazy/util.lua
@@ -5,18 +5,22 @@ function M.file_exists(file)
return vim.loop.fs_stat(file) ~= nil
end
----@param opts? LazyViewOptions
+---@param opts? LazyFloatOptions
function M.float(opts)
- opts = vim.tbl_deep_extend("force", {
- win_opts = { zindex = 60, border = "none" },
- margin = { top = 3, left = 2, right = 2 },
- }, opts or {})
+ opts = opts or {}
+ if require("lazy.view").visible() then
+ opts = vim.tbl_deep_extend("force", {
+ zindex = 60,
+ border = "none",
+ margin = { top = 3, left = 2, right = 2 },
+ }, opts)
+ end
return require("lazy.view.float")(opts)
end
function M.open(uri)
if M.file_exists(uri) then
- return M.float({ win_opts = { style = "" }, file = uri })
+ return M.float({ style = "", file = uri })
end
local Config = require("lazy.core.config")
local cmd
@@ -89,8 +93,13 @@ function M.throttle(ms, fn)
end
end
+---@class LazyCmdOpts
+---@field cwd? string
+---@field env? table
+---@field float? LazyFloatOptions
+
---@param cmd string[]
----@param opts? {cwd:string, filetype:string, terminal?:boolean, close_on_exit?:boolean, enter?:boolean, float?:LazyViewOptions}
+---@param opts? {cwd:string, filetype:string, terminal?:boolean, close_on_exit?:boolean, enter?:boolean, float?:LazyFloatOptions}
function M.open_cmd(cmd, opts)
opts = opts or {}
local float = M.float(opts.float)
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index 5539f35..6b22052 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -1,21 +1,21 @@
local Config = require("lazy.core.config")
local ViewConfig = require("lazy.view.config")
----@class LazyViewOptions
+---@class LazyFloatOptions
---@field buf? number
---@field file? string
---@field margin? {top?:number, right?:number, bottom?:number, left?:number}
----@field win_opts LazyViewWinOpts
---@field size? {width:number, height:number}
-local defaults = {
- win_opts = {},
-}
+---@field zindex? number
+---@field style? "" | "minimal"
+---@field border? "none" | "single" | "double" | "rounded" | "solid" | "shadow"
---@class LazyFloat
---@field buf number
---@field win number
----@field opts LazyViewOptions
----@overload fun(opts?:LazyViewOptions):LazyFloat
+---@field opts LazyFloatOptions
+---@field win_opts LazyWinOpts
+---@overload fun(opts?:LazyFloatOptions):LazyFloat
local M = {}
setmetatable(M, {
@@ -24,16 +24,33 @@ setmetatable(M, {
end,
})
----@param opts? LazyViewOptions
+---@param opts? LazyFloatOptions
function M.new(opts)
local self = setmetatable({}, { __index = M })
return self:init(opts)
end
----@param opts? LazyViewOptions
+---@param opts? LazyFloatOptions
function M:init(opts)
- self.opts = vim.tbl_deep_extend("force", defaults, opts or {})
- self.opts.size = vim.tbl_extend("keep", self.opts.size or {}, Config.options.ui.size)
+ self.opts = vim.tbl_deep_extend("force", {
+ size = Config.options.ui.size,
+ style = "minimal",
+ border = Config.options.ui.border,
+ zindex = 50,
+ }, opts or {})
+
+ ---@class LazyWinOpts
+ ---@field width number
+ ---@field height number
+ ---@field row number
+ ---@field col number
+ self.win_opts = {
+ relative = "editor",
+ style = self.opts.style ~= "" and self.opts.style or nil,
+ border = self.opts.border,
+ zindex = self.opts.zindex,
+ noautocmd = true,
+ }
self:mount()
self:on_key(ViewConfig.keys.close, self.close)
self:on({ "BufDelete", "BufLeave", "BufHidden" }, self.close, { once = true })
@@ -44,25 +61,25 @@ function M:layout()
local function size(max, value)
return value > 1 and math.min(value, max) or math.floor(max * value)
end
- self.opts.win_opts.width = size(vim.o.columns, self.opts.size.width)
- self.opts.win_opts.height = size(vim.o.lines, self.opts.size.height)
- self.opts.win_opts.row = math.floor((vim.o.lines - self.opts.win_opts.height) / 2)
- self.opts.win_opts.col = math.floor((vim.o.columns - self.opts.win_opts.width) / 2)
+ self.win_opts.width = size(vim.o.columns, self.opts.size.width)
+ self.win_opts.height = size(vim.o.lines, self.opts.size.height)
+ self.win_opts.row = math.floor((vim.o.lines - self.win_opts.height) / 2)
+ self.win_opts.col = math.floor((vim.o.columns - self.win_opts.width) / 2)
if self.opts.margin then
if self.opts.margin.top then
- self.opts.win_opts.height = self.opts.win_opts.height - self.opts.margin.top
- self.opts.win_opts.row = self.opts.win_opts.row + self.opts.margin.top
+ self.win_opts.height = self.win_opts.height - self.opts.margin.top
+ self.win_opts.row = self.win_opts.row + self.opts.margin.top
end
if self.opts.margin.right then
- self.opts.win_opts.width = self.opts.win_opts.width - self.opts.margin.right
+ self.win_opts.width = self.win_opts.width - self.opts.margin.right
end
if self.opts.margin.bottom then
- self.opts.win_opts.height = self.opts.win_opts.height - self.opts.margin.bottom
+ self.win_opts.height = self.win_opts.height - self.opts.margin.bottom
end
if self.opts.margin.left then
- self.opts.win_opts.width = self.opts.win_opts.width - self.opts.margin.left
- self.opts.win_opts.col = self.opts.win_opts.col + self.opts.margin.left
+ self.win_opts.width = self.win_opts.width - self.opts.margin.left
+ self.win_opts.col = self.win_opts.col + self.opts.margin.left
end
end
end
@@ -78,25 +95,8 @@ function M:mount()
self.buf = vim.api.nvim_create_buf(false, false)
end
- ---@class LazyViewWinOpts
- ---@field width number
- ---@field height number
- ---@field row number
- ---@field col number
- local win_opts = {
- relative = "editor",
- style = "minimal",
- border = Config.options.ui.border,
- noautocmd = true,
- zindex = 50,
- }
- self.opts.win_opts = vim.tbl_extend("force", win_opts, self.opts.win_opts)
- if self.opts.win_opts.style == "" then
- self.opts.win_opts.style = nil
- end
-
self:layout()
- self.win = vim.api.nvim_open_win(self.buf, true, self.opts.win_opts)
+ self.win = vim.api.nvim_open_win(self.buf, true, self.win_opts)
self:focus()
vim.bo[self.buf].buftype = "nofile"
@@ -118,7 +118,7 @@ function M:mount()
local config = {}
for _, key in ipairs({ "relative", "width", "height", "col", "row" }) do
---@diagnostic disable-next-line: no-unknown
- config[key] = self.opts.win_opts[key]
+ config[key] = self.win_opts[key]
end
vim.api.nvim_win_set_config(self.win, config)
vim.cmd([[do User LazyFloatResized]])
diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua
index cd91c4c..0f4e0d2 100644
--- a/lua/lazy/view/init.lua
+++ b/lua/lazy/view/init.lua
@@ -25,13 +25,17 @@ local M = {}
---@type LazyView
M.view = nil
+function M.visible()
+ return M.view and M.view.win and vim.api.nvim_win_is_valid(M.view.win)
+end
+
---@param mode? string
function M.show(mode)
if Config.headless then
return
end
- M.view = (M.view and M.view.win and vim.api.nvim_win_is_valid(M.view.win)) and M.view or M.create()
+ M.view = M.visible() and M.view or M.create()
if mode then
M.view.state.mode = mode
end
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index f5ce860..fd4b138 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -26,7 +26,7 @@ function M.new(view)
local self = setmetatable({}, { __index = setmetatable(M, { __index = Text }) })
self.view = view
self.padding = 2
- self.wrap = view.opts.win_opts.width
+ self.wrap = view.win_opts.width
return self
end
From e89e938991701cef7b9ace1913a7251c4c0fa46c Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 5 Jan 2023 17:36:01 +0100
Subject: [PATCH 014/992] refactor: split open_cmd in float_cmd and float_term
---
lua/lazy/core/config.lua | 10 ++-----
lua/lazy/util.lua | 65 +++++++++++++++++++++++-----------------
lua/lazy/view/diff.lua | 4 +--
3 files changed, 42 insertions(+), 37 deletions(-)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index d2b3146..f5441e0 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -72,21 +72,15 @@ M.defaults = {
-- open lazygit log
["l"] = function(plugin)
- require("lazy.util").open_cmd({ "lazygit", "log" }, {
+ require("lazy.util").float_term({ "lazygit", "log" }, {
cwd = plugin.dir,
- terminal = true,
- close_on_exit = true,
- enter = true,
})
end,
-- open a terminal for the plugin dir
["t"] = function(plugin)
- require("lazy.util").open_cmd({ vim.go.shell }, {
+ require("lazy.util").float_term(nil, {
cwd = plugin.dir,
- terminal = true,
- close_on_exit = true,
- enter = true,
})
end,
},
diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua
index d1b4257..edd6610 100644
--- a/lua/lazy/util.lua
+++ b/lua/lazy/util.lua
@@ -93,42 +93,53 @@ function M.throttle(ms, fn)
end
end
----@class LazyCmdOpts
+---@class LazyCmdOptions: LazyFloatOptions
---@field cwd? string
---@field env? table
---@field float? LazyFloatOptions
----@param cmd string[]
----@param opts? {cwd:string, filetype:string, terminal?:boolean, close_on_exit?:boolean, enter?:boolean, float?:LazyFloatOptions}
-function M.open_cmd(cmd, opts)
+-- Opens a floating terminal (interactive by default)
+---@param cmd? string[]|string
+---@param opts? LazyCmdOptions|{interactive?:boolean}
+function M.float_term(cmd, opts)
+ cmd = cmd or {}
+ if type(cmd) == "string" then
+ cmd = { cmd }
+ end
+ if #cmd == 0 then
+ cmd = { vim.env.SHELL or vim.o.shell }
+ end
opts = opts or {}
- local float = M.float(opts.float)
+ local float = M.float(opts)
+ vim.fn.termopen(cmd, vim.tbl_isempty(opts) and vim.empty_dict() or opts)
+ if opts.interactive ~= false then
+ vim.cmd.startinsert()
+ vim.api.nvim_create_autocmd("TermClose", {
+ once = true,
+ buffer = float.buf,
+ callback = function()
+ float:close()
+ vim.cmd.checktime()
+ end,
+ })
+ end
+ return float
+end
+--- Runs the command and shows it in a floating window
+---@param cmd string[]
+---@param opts? LazyCmdOptions|{filetype?:string}
+function M.float_cmd(cmd, opts)
+ opts = opts or {}
+ local float = M.float(opts)
if opts.filetype then
vim.bo[float.buf].filetype = opts.filetype
end
- if opts.terminal then
- opts.terminal = nil
- vim.fn.termopen(cmd, opts)
- if opts.enter then
- vim.cmd.startinsert()
- end
- if opts.close_on_exit then
- vim.api.nvim_create_autocmd("TermClose", {
- once = true,
- buffer = float.buf,
- callback = function()
- float:close()
- vim.cmd.checktime()
- end,
- })
- end
- else
- local Process = require("lazy.manage.process")
- local lines = Process.exec(cmd, { cwd = opts.cwd })
- vim.api.nvim_buf_set_lines(float.buf, 0, -1, false, lines)
- vim.bo[float.buf].modifiable = false
- end
+ local Process = require("lazy.manage.process")
+ local lines = Process.exec(cmd, { cwd = opts.cwd })
+ vim.api.nvim_buf_set_lines(float.buf, 0, -1, false, lines)
+ vim.bo[float.buf].modifiable = false
+ return float
end
---@return string?
diff --git a/lua/lazy/view/diff.lua b/lua/lazy/view/diff.lua
index 63dc2e7..24955b8 100644
--- a/lua/lazy/view/diff.lua
+++ b/lua/lazy/view/diff.lua
@@ -43,7 +43,7 @@ M.handlers = {
cmd[#cmd + 1] = diff.from
cmd[#cmd + 1] = diff.to
end
- Util.open_cmd(cmd, { cwd = plugin.dir, filetype = "git" })
+ Util.float_cmd(cmd, { cwd = plugin.dir, filetype = "git" })
end,
---@type LazyDiffFun
@@ -57,7 +57,7 @@ M.handlers = {
cmd[#cmd + 1] = diff.from
cmd[#cmd + 1] = diff.to
end
- Util.open_cmd(cmd, { cwd = plugin.dir, terminal = true, env = { PAGER = "cat" } })
+ Util.float_term(cmd, { cwd = plugin.dir, interactive = false, env = { PAGER = "cat" } })
end,
}
From 2ef44e2dee112ba7b83bdfca98f6c07967d65484 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 5 Jan 2023 19:43:47 +0100
Subject: [PATCH 015/992] fix(loader): revert change that loaded /plugin after
config. Fixes #328
---
lua/lazy/core/loader.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index aaffe94..c2bc844 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -217,10 +217,10 @@ function M._load(plugin, reason)
end, "Failed to load deps for " .. plugin.name)
end
+ M.packadd(plugin.dir)
if plugin.config then
M.config(plugin)
end
- M.packadd(plugin.dir)
plugin._.loaded.time = Util.track().time
table.remove(M.loading)
From eed1ef3c2d13b374def716ed7e9997595c466b3f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 6 Jan 2023 07:11:50 +0100
Subject: [PATCH 016/992] feat(commands): `:Lazy! load` now skips `cond` checks
when loading plugins. Fixes #330
---
README.md | 28 ++++++++++++++--------------
lua/lazy/core/loader.lua | 10 ++++++----
lua/lazy/view/commands.lua | 3 ++-
lua/lazy/view/config.lua | 2 +-
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 85020ab..21ab555 100644
--- a/README.md
+++ b/README.md
@@ -303,6 +303,8 @@ return {
version = nil,
-- version = "*", -- enable this to try installing the latest stable versions of plugins
},
+ -- leave nil when passing the spec as the first argument to setup()
+ spec = nil, ---@type LazySpec
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
concurrency = nil, ---@type number limit the maximum amount of concurrent tasks
git = {
@@ -330,20 +332,21 @@ return {
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
icons = {
- loaded = "●",
- not_loaded = "○",
cmd = " ",
config = "",
event = "",
ft = " ",
init = " ",
+ import = " ",
keys = " ",
+ lazy = "鈴 ",
+ loaded = "●",
+ not_loaded = "○",
plugin = " ",
runtime = " ",
source = " ",
start = "",
task = "✔ ",
- lazy = "鈴 ",
list = {
"●",
"➜",
@@ -361,21 +364,15 @@ return {
-- open lazygit log
["l"] = function(plugin)
- require("lazy.util").open_cmd({ "lazygit", "log" }, {
+ require("lazy.util").float_term({ "lazygit", "log" }, {
cwd = plugin.dir,
- terminal = true,
- close_on_exit = true,
- enter = true,
})
end,
-- open a terminal for the plugin dir
["t"] = function(plugin)
- require("lazy.util").open_cmd({ vim.go.shell }, {
+ require("lazy.util").float_term(nil, {
cwd = plugin.dir,
- terminal = true,
- close_on_exit = true,
- enter = true,
})
end,
},
@@ -410,7 +407,7 @@ return {
-- The default is to disable on:
-- * VimEnter: not useful to cache anything else beyond startup
-- * BufReadPre: this will be triggered early when opening a file from the command line directly
- disable_events = { "VimEnter", "BufReadPre" },
+ disable_events = { "UIEnter", "BufReadPre" },
ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
},
reset_packpath = true, -- reset the package path to improve startup time
@@ -498,7 +495,7 @@ Any operation can be started from the UI, with a sub command or an API function:
| `:Lazy help` | `require("lazy").help()` | Toggle this help page |
| `:Lazy home` | `require("lazy").home()` | Go back to plugin list |
| `:Lazy install [plugins]` | `require("lazy").install(opts?)` | Install missing plugins |
-| `:Lazy load {plugins}` | `require("lazy").load(opts)` | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim` |
+| `:Lazy load {plugins}` | `require("lazy").load(opts)` | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`. Use `:Lazy! load` to skip `cond` checks. |
| `:Lazy log [plugins]` | `require("lazy").log(opts?)` | Show recent updates |
| `:Lazy profile` | `require("lazy").profile()` | Show detailed profiling |
| `:Lazy restore [plugins]` | `require("lazy").restore(opts?)` | Updates all plugins to the state in the lockfile. For a single plugin: restore it to the state in the lockfile or to a given commit under the cursor |
@@ -532,9 +529,11 @@ Stats API (`require("lazy").stats()`):
-- when true, startuptime is the accurate cputime for the Neovim process. (Linux & Macos)
-- this is more accurate than `nvim --startuptime`, and as such will be slightly higher
-- when false, startuptime is calculated based on a delta with a timestamp when lazy started.
- startuptime_cputime = false,
+ real_cputime = false,
count = 0, -- total number of plugins
loaded = 0, -- number of loaded plugins
+ ---@type table
+ times = {},
}
```
@@ -738,6 +737,7 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
| **LazyReasonCmd** | **_Operator_** | |
| **LazyReasonEvent** | **_Constant_** | |
| **LazyReasonFt** | **_Character_** | |
+| **LazyReasonImport** | **_Identifier_** | |
| **LazyReasonKeys** | **_Statement_** | |
| **LazyReasonPlugin** | **_Special_** | |
| **LazyReasonRuntime** | **_@macro_** | |
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index c2bc844..235335b 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -157,7 +157,8 @@ end
---@class Loader
---@param plugins string|LazyPlugin|string[]|LazyPlugin[]
---@param reason {[string]:string}
-function M.load(plugins, reason)
+---@param opts? {force:boolean} when force is true, we skip the cond check
+function M.load(plugins, reason, opts)
---@diagnostic disable-next-line: cast-local-type
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
---@cast plugins (string|LazyPlugin)[]
@@ -174,19 +175,20 @@ function M.load(plugins, reason)
end
end
if plugin and not plugin._.loaded then
- M._load(plugin, reason)
+ M._load(plugin, reason, opts)
end
end
end
---@param plugin LazyPlugin
---@param reason {[string]:string}
-function M._load(plugin, reason)
+---@param opts? {force:boolean} when force is true, we skip the cond check
+function M._load(plugin, reason, opts)
if not plugin._.installed then
return Util.error("Plugin " .. plugin.name .. " is not installed")
end
- if plugin.cond ~= nil then
+ if plugin.cond ~= nil and not (opts and opts.force) then
if plugin.cond == false or (type(plugin.cond) == "function" and not plugin.cond()) then
plugin._.cond = false
return
diff --git a/lua/lazy/view/commands.lua b/lua/lazy/view/commands.lua
index 39bd3f8..4944e65 100644
--- a/lua/lazy/view/commands.lua
+++ b/lua/lazy/view/commands.lua
@@ -50,7 +50,8 @@ M.commands = {
end,
---@param opts ManagerOpts
load = function(opts)
- require("lazy.core.loader").load(opts.plugins, { cmd = "LazyLoad" })
+ -- when a command is executed with a bang, wait will be set
+ require("lazy.core.loader").load(opts.plugins, { cmd = "Lazy load" }, { force = opts.wait })
end,
log = Manage.log,
build = Manage.build,
diff --git a/lua/lazy/view/config.lua b/lua/lazy/view/config.lua
index e229352..b75c0f5 100644
--- a/lua/lazy/view/config.lua
+++ b/lua/lazy/view/config.lua
@@ -130,7 +130,7 @@ M.commands = {
id = 12,
},
load = {
- desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`",
+ desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`. Use `:Lazy! load` to skip `cond` checks.",
id = 13,
plugins = true,
plugins_required = true,
From 317df42fcf05761e2e8526d91f282a0f868ff766 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 6 Jan 2023 06:13:06 +0000
Subject: [PATCH 017/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 9f8d335..d7a0510 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 05
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 06
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
@@ -347,6 +347,8 @@ CONFIGURATION *lazy.nvim-configuration*
version = nil,
-- version = "", -- enable this to try installing the latest stable versions of plugins
},
+ -- leave nil when passing the spec as the first argument to setup()
+ spec = nil, ---@type LazySpec
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
concurrency = nil, ---@type number limit the maximum amount of concurrent tasks
git = {
@@ -374,20 +376,21 @@ CONFIGURATION *lazy.nvim-configuration*
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
icons = {
- loaded = "",
- not_loaded = "",
cmd = " ",
config = "",
event = "",
ft = " ",
init = " ",
+ import = " ",
keys = " ",
+ lazy = " ",
+ loaded = "",
+ not_loaded = "",
plugin = " ",
runtime = " ",
source = " ",
start = "",
task = " ",
- lazy = " ",
list = {
"",
"",
@@ -405,21 +408,15 @@ CONFIGURATION *lazy.nvim-configuration*
-- open lazygit log
["l"] = function(plugin)
- require("lazy.util").open_cmd({ "lazygit", "log" }, {
+ require("lazy.util").float_term({ "lazygit", "log" }, {
cwd = plugin.dir,
- terminal = true,
- close_on_exit = true,
- enter = true,
})
end,
-- open a terminal for the plugin dir
["t"] = function(plugin)
- require("lazy.util").open_cmd({ vim.go.shell }, {
+ require("lazy.util").float_term(nil, {
cwd = plugin.dir,
- terminal = true,
- close_on_exit = true,
- enter = true,
})
end,
},
@@ -454,7 +451,7 @@ CONFIGURATION *lazy.nvim-configuration*
-- The default is to disable on:
-- VimEnter: not useful to cache anything else beyond startup
-- BufReadPre: this will be triggered early when opening a file from the command line directly
- disable_events = { "VimEnter", "BufReadPre" },
+ disable_events = { "UIEnter", "BufReadPre" },
ttl = 3600 24 5, -- keep unused modules for up to 5 days
},
reset_packpath = true, -- reset the package path to improve startup time
@@ -537,7 +534,7 @@ function:
│:Lazy help │require("lazy").help() │Toggle this help page │
│:Lazy home │require("lazy").home() │Go back to plugin list │
│:Lazy install [plugins] │require("lazy").install(opts?) │Install missing plugins │
-│:Lazy load {plugins} │require("lazy").load(opts) │Load a plugin that has not been loaded yet. Similar to :packadd. Like :Lazy load foo.nvim │
+│:Lazy load {plugins} │require("lazy").load(opts) │Load a plugin that has not been loaded yet. Similar to :packadd. Like :Lazy load foo.nvim. Use :Lazy! load to skip cond checks. │
│:Lazy log [plugins] │require("lazy").log(opts?) │Show recent updates │
│:Lazy profile │require("lazy").profile() │Show detailed profiling │
│:Lazy restore [plugins] │require("lazy").restore(opts?) │Updates all plugins to the state in the lockfile. For a single plugin: restore it to the state in the lockfile or to a given commit under the cursor│
@@ -571,9 +568,11 @@ Stats API (`require("lazy").stats()`):
-- when true, startuptime is the accurate cputime for the Neovim process. (Linux & Macos)
-- this is more accurate than `nvim --startuptime`, and as such will be slightly higher
-- when false, startuptime is calculated based on a delta with a timestamp when lazy started.
- startuptime_cputime = false,
+ real_cputime = false,
count = 0, -- total number of plugins
loaded = 0, -- number of loaded plugins
+ ---@type table
+ times = {},
}
<
@@ -809,6 +808,7 @@ Click to see all highlight groups
│**LazyReasonCmd** │**_Operator_** │ │
│**LazyReasonEvent** │**_Constant_** │ │
│**LazyReasonFt** │**_Character_** │ │
+│**LazyReasonImport** │**_Identifier_** │ │
│**LazyReasonKeys** │**_Statement_** │ │
│**LazyReasonPlugin** │**_Special_** │ │
│**LazyReasonRuntime**│_macro │ │
From 4f76b431f73c912a7021bc17384533fbad96fba7 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 6 Jan 2023 11:18:48 +0100
Subject: [PATCH 018/992] refactor(util)!: `require("lazy.util").open_cmd()` is
deprecated. See the docs
---
lua/lazy/util.lua | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua
index edd6610..8e8a638 100644
--- a/lua/lazy/util.lua
+++ b/lua/lazy/util.lua
@@ -142,6 +142,11 @@ function M.float_cmd(cmd, opts)
return float
end
+---@deprecated use float_term or float_cmd instead
+function M.open_cmd()
+ M.warn([[`require("lazy.util").open_cmd()` is deprecated. Please use `float_term` instead. Check the docs]])
+end
+
---@return string?
function M.head(file)
local f = io.open(file)
From 102bc2722e73d0dcebd6c90b45a41cb33e0660cb Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 6 Jan 2023 19:16:39 +0100
Subject: [PATCH 019/992] fix(loader): source runtime files without `silent`.
Fixes #336
---
lua/lazy/core/loader.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 235335b..8ef6ee5 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -345,7 +345,7 @@ end
function M.source(path)
Util.track({ runtime = path })
Util.try(function()
- vim.cmd("silent source " .. path)
+ vim.cmd("source " .. path)
end, "Failed to source `" .. path .. "`")
Util.track()
end
From 7eadaacc48bd4d5eff375c1d303caff51e4ec99e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Fri, 6 Jan 2023 22:13:50 +0100
Subject: [PATCH 020/992] chore(main): release 8.0.0 (#329)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 76760e5..2332fb0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,27 @@
# Changelog
+## [8.0.0](https://github.com/folke/lazy.nvim/compare/v7.12.1...v8.0.0) (2023-01-06)
+
+
+### ⚠ BREAKING CHANGES
+
+* **util:** `require("lazy.util").open_cmd()` is deprecated. See the docs
+
+### Features
+
+* **commands:** `:Lazy! load` now skips `cond` checks when loading plugins. Fixes [#330](https://github.com/folke/lazy.nvim/issues/330) ([eed1ef3](https://github.com/folke/lazy.nvim/commit/eed1ef3c2d13b374def716ed7e9997595c466b3f))
+
+
+### Bug Fixes
+
+* **loader:** revert change that loaded /plugin after config. Fixes [#328](https://github.com/folke/lazy.nvim/issues/328) ([2ef44e2](https://github.com/folke/lazy.nvim/commit/2ef44e2dee112ba7b83bdfca98f6c07967d65484))
+* **loader:** source runtime files without `silent`. Fixes [#336](https://github.com/folke/lazy.nvim/issues/336) ([102bc27](https://github.com/folke/lazy.nvim/commit/102bc2722e73d0dcebd6c90b45a41cb33e0660cb))
+
+
+### Code Refactoring
+
+* **util:** `require("lazy.util").open_cmd()` is deprecated. See the docs ([4f76b43](https://github.com/folke/lazy.nvim/commit/4f76b431f73c912a7021bc17384533fbad96fba7))
+
## [7.12.1](https://github.com/folke/lazy.nvim/compare/v7.12.0...v7.12.1) (2023-01-05)
From 05b55deb16f074f2a44b81927c2e5feb63fba651 Mon Sep 17 00:00:00 2001
From: Brian Koropoff
Date: Sat, 7 Jan 2023 00:01:45 -0800
Subject: [PATCH 021/992] fix(config): Don't cache check for attached UIs
(#340)
UIs can attach and detach from headless nvim dynamically
(indeed, this is one of its use cases).
---
lua/lazy/core/config.lua | 6 ++++--
lua/lazy/view/init.lua | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index f5441e0..c83a09a 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -159,7 +159,9 @@ M.me = nil
---@type string
M.mapleader = nil
-M.headless = #vim.api.nvim_list_uis() == 0
+function M.headless()
+ return #vim.api.nvim_list_uis() == 0
+end
---@param opts? LazyConfig
function M.setup(opts)
@@ -200,7 +202,7 @@ function M.setup(opts)
vim.go.loadplugins = false
M.mapleader = vim.g.mapleader
- if M.headless then
+ if M.headless() then
require("lazy.view.commands").setup()
else
vim.api.nvim_create_autocmd("UIEnter", {
diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua
index 0f4e0d2..ac64e74 100644
--- a/lua/lazy/view/init.lua
+++ b/lua/lazy/view/init.lua
@@ -31,7 +31,7 @@ end
---@param mode? string
function M.show(mode)
- if Config.headless then
+ if Config.headless() then
return
end
From 457e65eec8a7be03f634d3e880b0e7cd03349265 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sat, 7 Jan 2023 08:02:29 +0000
Subject: [PATCH 022/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index d7a0510..5e62d74 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 06
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 07
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 5ed89b5a0d6be65ec9fd0f6526c8c27a922f50a1 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sat, 7 Jan 2023 09:12:51 +0100
Subject: [PATCH 023/992] fix(config): properly handle uis connecting after
startup
---
lua/lazy/core/config.lua | 49 ++++++++++++++++++------------------
lua/lazy/core/util.lua | 1 +
lua/lazy/manage/checker.lua | 2 +-
lua/lazy/manage/reloader.lua | 2 +-
4 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index c83a09a..372bc70 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -160,7 +160,7 @@ M.me = nil
M.mapleader = nil
function M.headless()
- return #vim.api.nvim_list_uis() == 0
+ return #vim.api.nvim_list_uis() == 0
end
---@param opts? LazyConfig
@@ -204,31 +204,32 @@ function M.setup(opts)
if M.headless() then
require("lazy.view.commands").setup()
- else
- vim.api.nvim_create_autocmd("UIEnter", {
- callback = function()
- require("lazy.stats").on_ui_enter()
- end,
- })
-
- vim.api.nvim_create_autocmd("User", {
- pattern = "VeryLazy",
- once = true,
- callback = function()
- require("lazy.core.cache").autosave()
- require("lazy.view.commands").setup()
- if M.options.change_detection.enabled then
- require("lazy.manage.reloader").enable()
- end
- if M.options.checker.enabled then
- vim.defer_fn(function()
- require("lazy.manage.checker").start()
- end, 10)
- end
- end,
- })
end
+ vim.api.nvim_create_autocmd("UIEnter", {
+ once = true,
+ callback = function()
+ require("lazy.stats").on_ui_enter()
+ end,
+ })
+
+ vim.api.nvim_create_autocmd("User", {
+ pattern = "VeryLazy",
+ once = true,
+ callback = function()
+ require("lazy.core.cache").autosave()
+ require("lazy.view.commands").setup()
+ if M.options.change_detection.enabled then
+ require("lazy.manage.reloader").enable()
+ end
+ if M.options.checker.enabled then
+ vim.defer_fn(function()
+ require("lazy.manage.checker").start()
+ end, 10)
+ end
+ end,
+ })
+
Util.very_lazy()
end
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 48582c0..5111566 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -142,6 +142,7 @@ end
function M.very_lazy()
local function _load()
vim.defer_fn(function()
+ vim.g.did_very_lazy = true
vim.cmd("do User VeryLazy")
end, 50)
end
diff --git a/lua/lazy/manage/checker.lua b/lua/lazy/manage/checker.lua
index 5597bbc..477c63d 100644
--- a/lua/lazy/manage/checker.lua
+++ b/lua/lazy/manage/checker.lua
@@ -65,7 +65,7 @@ function M.report(notify)
end
end
end
- if #lines > 0 and notify and Config.options.checker.notify then
+ if #lines > 0 and notify and Config.options.checker.notify and not Config.headless() then
table.insert(lines, 1, "# Plugin Updates")
Util.info(lines)
end
diff --git a/lua/lazy/manage/reloader.lua b/lua/lazy/manage/reloader.lua
index d338775..5f9a74b 100644
--- a/lua/lazy/manage/reloader.lua
+++ b/lua/lazy/manage/reloader.lua
@@ -75,7 +75,7 @@ function M.check(start)
if not (start or #changes == 0) then
vim.schedule(function()
- if Config.options.change_detection.notify then
+ if Config.options.change_detection.notify and not Config.headless() then
local lines = { "# Config Change Detected. Reloading...", "" }
for _, change in ipairs(changes) do
table.insert(lines, "- **" .. change.what .. "**: `" .. vim.fn.fnamemodify(change.file, ":p:~:.") .. "`")
From c3132492714661121f70daf77d716053ab39bd0b Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sat, 7 Jan 2023 09:37:03 +0100
Subject: [PATCH 024/992] feat(spec): show error when loading two specs with
the same name and a different url. Fixes #337
---
lua/lazy/core/plugin.lua | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index e9af209..fe3a34b 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -250,6 +250,10 @@ end
function Spec:merge(old, new)
new._.dep = old._.dep and new._.dep
+ if new.url and old.url and new.url ~= old.url then
+ self:error("Two plugins with the same name and different url:\n" .. vim.inspect({ old = old, new = new }))
+ end
+
for _, prop in ipairs(list_merge) do
if new[prop] and old[prop] then
---@type any[]
From ae12dd9686d26643f79a6e9966d50e6a8e92f8be Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sat, 7 Jan 2023 12:08:31 +0100
Subject: [PATCH 025/992] docs: updated LazyVim links
---
README.md | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 21ab555..2667426 100644
--- a/README.md
+++ b/README.md
@@ -656,12 +656,10 @@ return {
- any lua file in `~/.config/nvim/lua/plugins/*.lua` will be automatically merged in the main plugin spec
-For a real-life example, you can check [LazyVim](https://github.com/folke/LazyVim),
+For a real-life example, you can check [LazyVim](https://github.com/LazyVim/LazyVim),
a starter template for lazy Neovim users.
-- [init.lua](https://github.com/folke/LazyVim/blob/main/init.lua) where `lazyvim.config.lazy` is required
-- [lazyvim.config.lazy](https://github.com/folke/LazyVim/blob/main/lua/lazyvim/config/lazy.lua) where we setup **lazy.nvim**
-- [lazyvim.plugins](https://github.com/folke/LazyVim/tree/main/lua/lazyvim/plugins) contains all the plugin specs that will be loaded
+- [lazyvim.plugins](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/plugins) contains all the plugin specs that will be loaded
## 📦 Migration Guide
From a1c926f87b7a4c9d0642a76c1205623045541568 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sat, 7 Jan 2023 11:09:20 +0000
Subject: [PATCH 026/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 5e62d74..2cefafa 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -718,12 +718,10 @@ Example:
For a real-life example, you can check LazyVim
-, a starter template for lazy Neovim users.
+, a starter template for lazy Neovim users.
-- init.lua where `lazyvim.config.lazy` is required
-- lazyvim.config.lazy where we setup **lazy.nvim**
-- lazyvim.plugins contains all the plugin specs that will be loaded
+- lazyvim.plugins contains all the plugin specs that will be loaded
MIGRATION GUIDE *lazy.nvim-migration-guide*
From 735f2a280ee4b6d3c41b8d54f228fbf0a00f3755 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sat, 7 Jan 2023 12:10:19 +0100
Subject: [PATCH 027/992] docs: LazyVim
---
README.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 2667426..a237743 100644
--- a/README.md
+++ b/README.md
@@ -656,8 +656,7 @@ return {
- any lua file in `~/.config/nvim/lua/plugins/*.lua` will be automatically merged in the main plugin spec
-For a real-life example, you can check [LazyVim](https://github.com/LazyVim/LazyVim),
-a starter template for lazy Neovim users.
+For a real-life example, you can check [LazyVim](https://github.com/LazyVim/LazyVim) and more specifically:
- [lazyvim.plugins](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/plugins) contains all the plugin specs that will be loaded
From 8798ccc95031225e3b2241bd8b2d26c2452b06c4 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sat, 7 Jan 2023 11:11:08 +0000
Subject: [PATCH 028/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 2cefafa..674c173 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -718,7 +718,7 @@ Example:
For a real-life example, you can check LazyVim
-, a starter template for lazy Neovim users.
+ and more specifically:
- lazyvim.plugins contains all the plugin specs that will be loaded
From d34c85d58007f37f9eb60fe0c1075950a5ce615e Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sat, 7 Jan 2023 22:24:46 +0100
Subject: [PATCH 029/992] fix(cache): check that modpaths still exist when
finding mod root
---
lua/lazy/core/cache.lua | 4 +--
tests/core/util_spec.lua | 59 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index edba74a..709e321 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -262,7 +262,7 @@ function M.find_root(modname)
if M.cache[modname] then
-- check if modname is in cache
local modpath = M.cache[modname].modpath
- if M.check_path(modname, modpath) then
+ if M.check_path(modname, modpath) and vim.loop.fs_stat(modpath) then
local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
return root
end
@@ -271,7 +271,7 @@ function M.find_root(modname)
-- check for any children in the cache
for child, entry in pairs(M.cache) do
if child:find(modname, 1, true) == 1 then
- if M.check_path(child, entry.modpath) then
+ if M.check_path(child, entry.modpath) and vim.loop.fs_stat(entry.modpath) then
local basename = modname:gsub("%.", "/")
local childbase = child:gsub("%.", "/")
local ret = entry.modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
diff --git a/tests/core/util_spec.lua b/tests/core/util_spec.lua
index 655b71f..53566a3 100644
--- a/tests/core/util_spec.lua
+++ b/tests/core/util_spec.lua
@@ -3,11 +3,19 @@ local Cache = require("lazy.core.cache")
local Helpers = require("tests.helpers")
describe("util", function()
+ local rtp = vim.opt.rtp:get()
before_each(function()
+ vim.opt.rtp = rtp
+ for k, v in pairs(package.loaded) do
+ if k:find("^foobar") then
+ package.loaded[k] = nil
+ end
+ end
Helpers.fs_rm("")
end)
it("lsmod lists all mods in dir", function()
+ vim.opt.rtp:append(Helpers.path(""))
local tests = {
{
root = "lua/foo",
@@ -35,7 +43,6 @@ describe("util", function()
},
}
- vim.opt.rtp:append(Helpers.path(""))
for t, test in ipairs(tests) do
local expected = vim.deepcopy(test.mods)
table.sort(expected)
@@ -74,4 +81,54 @@ describe("util", function()
assert.same(expected, mods)
end
end)
+
+ it("find the correct root with dels", function()
+ Cache.cache = {}
+ Cache.indexed = {}
+ Cache.indexed_rtp = false
+ vim.opt.rtp:append(Helpers.path("old"))
+ Helpers.fs_create({ "old/lua/foobar/init.lua" })
+ require("foobar")
+ local root = Cache.find_root("foobar")
+ assert(root, "foobar root not found")
+ assert.same(Helpers.path("old/lua/foobar"), root)
+
+ Helpers.fs_rm("old/")
+
+ -- vim.opt.rtp = rtp
+ Cache.indexed = {}
+ Cache.indexed_rtp = false
+ vim.opt.rtp:append(Helpers.path("new"))
+ Helpers.fs_create({ "new/lua/foobar/init.lua" })
+ root = Cache.find_root("foobar")
+ assert(root, "foobar root not found")
+ assert.same(Helpers.path("new/lua/foobar"), root)
+ end)
+
+ it("find the correct root with mod dels", function()
+ Cache.cache = {}
+ Cache.indexed = {}
+ Cache.indexed_rtp = false
+ Cache.topmods = {}
+ Cache.enabled = true
+ vim.opt.rtp:append(Helpers.path("old"))
+ Helpers.fs_create({ "old/lua/foobar/test.lua" })
+ Cache.cache["foobar.test"] = { modpath = Helpers.path("old/lua/foobar/test.lua") }
+ local root = Cache.find_root("foobar")
+ assert(root, "foobar root not found")
+ assert.same(Helpers.path("old/lua/foobar"), root)
+ assert(not Cache.cache["foobar"], "foobar should not be in cache")
+ assert(Cache.cache["foobar.test"], "foobar.test not found in cache")
+
+ Helpers.fs_rm("old/")
+
+ -- vim.opt.rtp = rtp
+ Cache.indexed = {}
+ Cache.indexed_rtp = false
+ vim.opt.rtp:append(Helpers.path("new"))
+ Helpers.fs_create({ "new/lua/foobar/test.lua" })
+ root = Cache.find_root("foobar")
+ assert(root, "foobar root not found")
+ assert.same(Helpers.path("new/lua/foobar"), root)
+ end)
end)
From ad00eb1be2f79da81924e01f3804ea24caa75f82 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sat, 7 Jan 2023 22:52:49 +0100
Subject: [PATCH 030/992] test: fixed helper function to delete test directory
---
lua/lazy/core/cache.lua | 4 ++--
tests/core/util_spec.lua | 9 +++++----
tests/helpers.lua | 2 +-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 709e321..09792bc 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -262,7 +262,7 @@ function M.find_root(modname)
if M.cache[modname] then
-- check if modname is in cache
local modpath = M.cache[modname].modpath
- if M.check_path(modname, modpath) and vim.loop.fs_stat(modpath) then
+ if M.check_path(modname, modpath) and uv.fs_stat(modpath) then
local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
return root
end
@@ -271,7 +271,7 @@ function M.find_root(modname)
-- check for any children in the cache
for child, entry in pairs(M.cache) do
if child:find(modname, 1, true) == 1 then
- if M.check_path(child, entry.modpath) and vim.loop.fs_stat(entry.modpath) then
+ if M.check_path(child, entry.modpath) and uv.fs_stat(entry.modpath) then
local basename = modname:gsub("%.", "/")
local childbase = child:gsub("%.", "/")
local ret = entry.modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
diff --git a/tests/core/util_spec.lua b/tests/core/util_spec.lua
index 53566a3..7349c68 100644
--- a/tests/core/util_spec.lua
+++ b/tests/core/util_spec.lua
@@ -12,6 +12,7 @@ describe("util", function()
end
end
Helpers.fs_rm("")
+ assert(not vim.loop.fs_stat(Helpers.path("")), "fs root should be deleted")
end)
it("lsmod lists all mods in dir", function()
@@ -88,12 +89,13 @@ describe("util", function()
Cache.indexed_rtp = false
vim.opt.rtp:append(Helpers.path("old"))
Helpers.fs_create({ "old/lua/foobar/init.lua" })
- require("foobar")
+ Cache.cache["foobar"] = { modpath = Helpers.path("old/lua/foobar/init.lua") }
local root = Cache.find_root("foobar")
assert(root, "foobar root not found")
assert.same(Helpers.path("old/lua/foobar"), root)
- Helpers.fs_rm("old/")
+ Helpers.fs_rm("old")
+ assert(not vim.loop.fs_stat(Helpers.path("old/lua/foobar")), "old/lua/foobar should not exist")
-- vim.opt.rtp = rtp
Cache.indexed = {}
@@ -109,7 +111,6 @@ describe("util", function()
Cache.cache = {}
Cache.indexed = {}
Cache.indexed_rtp = false
- Cache.topmods = {}
Cache.enabled = true
vim.opt.rtp:append(Helpers.path("old"))
Helpers.fs_create({ "old/lua/foobar/test.lua" })
@@ -120,7 +121,7 @@ describe("util", function()
assert(not Cache.cache["foobar"], "foobar should not be in cache")
assert(Cache.cache["foobar.test"], "foobar.test not found in cache")
- Helpers.fs_rm("old/")
+ Helpers.fs_rm("old")
-- vim.opt.rtp = rtp
Cache.indexed = {}
diff --git a/tests/helpers.lua b/tests/helpers.lua
index c6174a8..48d84f9 100644
--- a/tests/helpers.lua
+++ b/tests/helpers.lua
@@ -23,7 +23,7 @@ function M.fs_create(files)
end
function M.fs_rm(dir)
- dir = Util.norm(M.fs_root .. dir)
+ dir = Util.norm(M.fs_root .. "/" .. dir)
Util.walk(dir, function(path, _, type)
if type == "directory" then
vim.loop.fs_rmdir(path)
From 8a3754717162cd453abd8da87a6020beaba17994 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Sat, 7 Jan 2023 22:59:05 +0100
Subject: [PATCH 031/992] chore(main): release 8.1.0 (#341)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2332fb0..b02ae2f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## [8.1.0](https://github.com/folke/lazy.nvim/compare/v8.0.0...v8.1.0) (2023-01-07)
+
+
+### Features
+
+* **spec:** show error when loading two specs with the same name and a different url. Fixes [#337](https://github.com/folke/lazy.nvim/issues/337) ([c313249](https://github.com/folke/lazy.nvim/commit/c3132492714661121f70daf77d716053ab39bd0b))
+
+
+### Bug Fixes
+
+* **cache:** check that modpaths still exist when finding mod root ([d34c85d](https://github.com/folke/lazy.nvim/commit/d34c85d58007f37f9eb60fe0c1075950a5ce615e))
+* **config:** Don't cache check for attached UIs ([#340](https://github.com/folke/lazy.nvim/issues/340)) ([05b55de](https://github.com/folke/lazy.nvim/commit/05b55deb16f074f2a44b81927c2e5feb63fba651))
+* **config:** properly handle uis connecting after startup ([5ed89b5](https://github.com/folke/lazy.nvim/commit/5ed89b5a0d6be65ec9fd0f6526c8c27a922f50a1))
+
## [8.0.0](https://github.com/folke/lazy.nvim/compare/v7.12.1...v8.0.0) (2023-01-06)
From a39fa0f0ced7324800eff0a4eb0ed68bf13452d1 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 8 Jan 2023 08:04:34 +0100
Subject: [PATCH 032/992] feat(git): added fast `Git.get_origin` and
`Git.get_config`
---
lua/lazy/manage/git.lua | 32 ++++++++++++++++++++++++++++++++
tests/core/e2e_spec.lua | 4 ++++
2 files changed, 36 insertions(+)
diff --git a/lua/lazy/manage/git.lua b/lua/lazy/manage/git.lua
index f104c5e..76f7009 100644
--- a/lua/lazy/manage/git.lua
+++ b/lua/lazy/manage/git.lua
@@ -193,4 +193,36 @@ function M.get_tag_refs(repo, tagref)
return tags
end
+---@param repo string
+function M.get_origin(repo)
+ return M.get_config(repo)["remote.origin.url"]
+end
+
+---@param repo string
+function M.get_config(repo)
+ local ok, config = pcall(Util.read_file, repo .. "/.git/config")
+ if not ok then
+ return {}
+ end
+ ---@type table
+ local ret = {}
+ ---@type string
+ local current_section = nil
+ for line in config:gmatch("[^\n]+") do
+ -- Check if the line is a section header
+ local section = line:match("^%s*%[(.+)%]%s*$")
+ if section then
+ ---@type string
+ current_section = section:gsub('%s+"', "."):gsub('"+%s*$', "")
+ else
+ -- Ignore comments and blank lines
+ if not line:match("^%s*#") and line:match("%S") then
+ local key, value = line:match("^%s*(%S+)%s*=%s*(.+)%s*$")
+ ret[current_section .. "." .. key] = value
+ end
+ end
+ end
+ return ret
+end
+
return M
diff --git a/tests/core/e2e_spec.lua b/tests/core/e2e_spec.lua
index db59155..a7d02fc 100644
--- a/tests/core/e2e_spec.lua
+++ b/tests/core/e2e_spec.lua
@@ -1,3 +1,5 @@
+local Git = require("lazy.manage.git")
+
describe("lazy", function()
before_each(function()
vim.g.lazy_did_setup = false
@@ -31,5 +33,7 @@ describe("lazy", function()
assert(not neodev)
assert(Config.plugins["neodev.nvim"]._.installed)
assert(not Config.plugins["neodev.nvim"]._.is_local)
+ assert.equal("https://github.com/folke/neodev.nvim.git", Git.get_origin(Config.plugins["neodev.nvim"].dir))
+ assert.equal("https://github.com/folke/paint.nvim.git", Git.get_origin(Config.plugins["paint.nvim"].dir))
end)
end)
From 615781aebfc0230669a2e5750cba3c65f0b8a90e Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 8 Jan 2023 08:32:03 +0100
Subject: [PATCH 033/992] feat(git): lazy now detects origin changes and will
fix it on update. Fixes #346. Fixes #331
---
lua/lazy/manage/init.lua | 7 ++++++-
lua/lazy/manage/task/git.lua | 24 ++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua
index 375f445..d14a7b8 100644
--- a/lua/lazy/manage/init.lua
+++ b/lua/lazy/manage/init.lua
@@ -94,6 +94,7 @@ function M.update(opts)
opts = M.opts(opts, { mode = "update" })
return M.run({
pipeline = {
+ "git.origin",
"git.branch",
"git.fetch",
{ "git.checkout", lockfile = opts.lockfile },
@@ -123,6 +124,7 @@ function M.check(opts)
opts = opts or {}
return M.run({
pipeline = {
+ { "git.origin", check = true },
"git.fetch",
"wait",
{ "git.log", check = true },
@@ -137,7 +139,10 @@ end
function M.log(opts)
opts = M.opts(opts, { mode = "log" })
return M.run({
- pipeline = { "git.log" },
+ pipeline = {
+ { "git.origin", check = true },
+ "git.log",
+ },
plugins = function(plugin)
return plugin.url and plugin._.installed
end,
diff --git a/lua/lazy/manage/task/git.lua b/lua/lazy/manage/task/git.lua
index 57388a6..c314c90 100644
--- a/lua/lazy/manage/task/git.lua
+++ b/lua/lazy/manage/task/git.lua
@@ -113,6 +113,30 @@ M.branch = {
end,
}
+-- check and switch origin
+M.origin = {
+ skip = function(plugin)
+ if not plugin._.installed or plugin._.is_local then
+ return true
+ end
+ local origin = Git.get_origin(plugin.dir)
+ return origin == plugin.url
+ end,
+ ---@param opts {check?:boolean}
+ run = function(self, opts)
+ if opts.check then
+ local origin = Git.get_origin(self.plugin.dir)
+ self.error = "Origin has changed:\n"
+ self.error = self.error .. " * old: " .. origin .. "\n"
+ self.error = self.error .. " * new: " .. self.plugin.url .. "\n"
+ self.error = self.error .. "Please run update to fix"
+ return
+ end
+ require("lazy.manage.task.fs").clean.run(self, opts)
+ M.clone.run(self, opts)
+ end,
+}
+
-- fetches all needed origin branches
M.fetch = {
skip = function(plugin)
From b178daf9dc95b9171ead57a89ea81239cadda2ec Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sun, 8 Jan 2023 07:32:49 +0000
Subject: [PATCH 034/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 674c173..0ff1888 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 07
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 08
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 6a31b97e3729af3710207642968e1492071a7dbc Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 8 Jan 2023 14:58:17 +0100
Subject: [PATCH 035/992] feat(util): better deep merging with `Util.merge`
---
lua/lazy/core/util.lua | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 5111566..70c1eb8 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -286,4 +286,31 @@ function M.debug(msg, level, opts)
end
end
+local function can_merge(v)
+ return type(v) == "table" and (vim.tbl_isempty(v) or not M.is_list(v))
+end
+
+--- Merges the values similar to vim.tbl_deep_extend with the **force** behavior,
+--- but the values can be any type, in which case they override the values on the left.
+--- Values will me merged in-place in the first left-most table. If you want the result to be in
+--- a new table, then simply pass an empty table as the first argument `vim.merge({}, ...)`
+--- Supports clearing values by setting a key to `vim.NIL`
+function M.merge(...)
+ local values = { ... }
+ local ret = values[1]
+ for i = 2, #values, 1 do
+ local value = values[i]
+ if can_merge(ret) and can_merge(value) then
+ for k, v in pairs(value) do
+ ret[k] = M.merge(ret[k], v)
+ end
+ elseif value == vim.NIL then
+ ret = nil
+ else
+ ret = value
+ end
+ end
+ return ret
+end
+
return M
From 7260a2b28be807c4bdc1caf23fa35c2aa33aa6ac Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 8 Jan 2023 15:01:49 +0100
Subject: [PATCH 036/992] feat(spec)!: setting a table to `Plugin.config` is
now deprecated. Please use `Plugin.opts` instead. (backward compatible for
now)
---
README.md | 73 ++++++++++++++++++++++++--------------
lua/lazy/core/loader.lua | 27 +++++++++++---
lua/lazy/core/plugin.lua | 9 +++++
lua/lazy/example.lua | 4 +--
lua/lazy/health.lua | 52 +++++++++++++++------------
lua/lazy/types.lua | 9 +++--
tests/core/plugin_spec.lua | 35 ++++++++++++++++++
7 files changed, 150 insertions(+), 59 deletions(-)
diff --git a/README.md b/README.md
index a237743..594b1ae 100644
--- a/README.md
+++ b/README.md
@@ -79,31 +79,32 @@ require("lazy").setup({
## 🔌 Plugin Spec
-| Property | Type | Description |
-| ---------------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `[1]` | `string?` | Short plugin url. Will be expanded using `config.git.url_format` |
-| **dir** | `string?` | A directory pointing to a local plugin |
-| **url** | `string?` | A custom git url where the plugin is hosted |
-| **name** | `string?` | A custom name for the plugin used for the local plugin directory and as the display name |
-| **dev** | `boolean?` | When `true`, a local plugin directory will be used instead. See `config.dev` |
-| **lazy** | `boolean?` | When `true`, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are `required`, or when one of the lazy-loading handlers triggers |
-| **enabled** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be included in the spec |
-| **cond** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. |
-| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
-| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
-| **config** | `fun(LazyPlugin)` or `true` or `table` | `config` is executed when the plugin loads. You can also set to `true` or pass a `table`, that will be passed to `require("plugin").setup(opts)` |
-| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
-| **branch** | `string?` | Branch of the repository |
-| **tag** | `string?` | Tag of the repository |
-| **commit** | `string?` | Commit of the repository |
-| **version** | `string?` | Version to use from the repository. Full [Semver](https://devhints.io/semver) ranges are supported |
-| **pin** | `boolean?` | When `true`, this plugin will not be included in updates |
-| **event** | `string?` or `string[]` | Lazy-load on event. Events can be specified as `BufEnter` or with a pattern like `BufEnter *.lua` |
-| **cmd** | `string?` or `string[]` | Lazy-load on command |
-| **ft** | `string?` or `string[]` | Lazy-load on filetype |
-| **keys** | `string?` or `string[]` or `LazyKeys[]` | Lazy-load on key mapping |
-| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
-| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
+| Property | Type | Description |
+| ---------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `[1]` | `string?` | Short plugin url. Will be expanded using `config.git.url_format` |
+| **dir** | `string?` | A directory pointing to a local plugin |
+| **url** | `string?` | A custom git url where the plugin is hosted |
+| **name** | `string?` | A custom name for the plugin used for the local plugin directory and as the display name |
+| **dev** | `boolean?` | When `true`, a local plugin directory will be used instead. See `config.dev` |
+| **lazy** | `boolean?` | When `true`, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are `required`, or when one of the lazy-loading handlers triggers |
+| **enabled** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be included in the spec |
+| **cond** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. |
+| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
+| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
+| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. You can also set it to `true`, to automatically run `require("plugin").setup(opts)`. See also `opts`. |
+| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
+| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
+| **branch** | `string?` | Branch of the repository |
+| **tag** | `string?` | Tag of the repository |
+| **commit** | `string?` | Commit of the repository |
+| **version** | `string?` | Version to use from the repository. Full [Semver](https://devhints.io/semver) ranges are supported |
+| **pin** | `boolean?` | When `true`, this plugin will not be included in updates |
+| **event** | `string?` or `string[]` | Lazy-load on event. Events can be specified as `BufEnter` or with a pattern like `BufEnter *.lua` |
+| **cmd** | `string?` or `string[]` | Lazy-load on command |
+| **ft** | `string?` or `string[]` | Lazy-load on filetype |
+| **keys** | `string?` or `string[]` or `LazyKeys[]` | Lazy-load on key mapping |
+| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
+| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
### Lazy Loading
@@ -224,11 +225,11 @@ return {
config = true, -- run require("neorg").setup()
},
- -- or set a custom config:
+ -- or set custom options:
{
"nvim-neorg/neorg",
ft = "norg",
- config = { foo = "bar" }, -- run require("neorg").setup({foo = "bar"})
+ opts = { foo = "bar" }, -- run require("neorg").setup({foo = "bar"})
},
{
@@ -660,6 +661,24 @@ For a real-life example, you can check [LazyVim](https://github.com/LazyVim/Lazy
- [lazyvim.plugins](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/plugins) contains all the plugin specs that will be loaded
+### ↩️ Importing Specs, `config` & `opts`
+
+As part of a spec, you can add `import` statements to import additional plugin modules.
+Both of the `setup()` calls are equivalent:
+
+```lua
+require("lazy").setup("plugins")
+
+-- same as:
+require("lazy").setup({{import = "plugins"}})
+```
+
+When you import specs, you can override them by simply adding a spec for the same plugin to your local
+specs, adding any keys you want to override / merge.
+
+`opts`, `dependencies`, `cmd`, `event`, `ft` and `keys` are always merged with the parent spec.
+Any other property will override the property from the parent spec.
+
## 📦 Migration Guide
### [packer.nvim](https://github.com/wbthomason/packer.nvim)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 8ef6ee5..9054d32 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -220,7 +220,7 @@ function M._load(plugin, reason, opts)
end
M.packadd(plugin.dir)
- if plugin.config then
+ if plugin.config or plugin.opts then
M.config(plugin)
end
@@ -231,13 +231,32 @@ function M._load(plugin, reason, opts)
end)
end
+-- Merges super opts or runs the opts function to override opts or return new ones
+---@param plugin LazyPlugin
+function M.opts(plugin)
+ local opts = plugin._.super and M.opts(plugin._.super) or {}
+ ---@type PluginOpts?
+ local plugin_opts = rawget(plugin, "opts")
+
+ if type(plugin_opts) == "table" then
+ opts = Util.merge(opts, plugin_opts)
+ elseif type(plugin_opts) == "function" then
+ local new_opts = plugin_opts(plugin, opts)
+ if new_opts then
+ opts = new_opts
+ end
+ end
+
+ return opts
+end
+
--- runs plugin config
---@param plugin LazyPlugin
function M.config(plugin)
local fn
if type(plugin.config) == "function" then
fn = function()
- plugin.config(plugin)
+ plugin.config(plugin, M.opts(plugin))
end
else
local normname = Util.normname(plugin.name)
@@ -254,8 +273,8 @@ function M.config(plugin)
end
if #mods == 1 then
fn = function()
- local opts = plugin.config
- if opts == true then
+ local opts = M.opts(plugin)
+ if next(opts) == nil then
opts = nil
end
require(mods[1]).setup(opts)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index fe3a34b..d955b49 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -87,6 +87,15 @@ function Spec:add(plugin, results, is_dep)
plugin.cmd = type(plugin.cmd) == "string" and { plugin.cmd } or plugin.cmd
plugin.ft = type(plugin.ft) == "string" and { plugin.ft } or plugin.ft
+ if type(plugin.config) == "table" then
+ self:warn(
+ "{" .. plugin.name .. "}: setting a table to `Plugin.config` is deprecated. Please use `Plugin.opts` instead"
+ )
+ ---@diagnostic disable-next-line: assign-type-mismatch
+ plugin.opts = plugin.config
+ plugin.config = nil
+ end
+
plugin._ = {}
plugin._.dep = is_dep
diff --git a/lua/lazy/example.lua b/lua/lazy/example.lua
index 93f87d4..18c1ca9 100644
--- a/lua/lazy/example.lua
+++ b/lua/lazy/example.lua
@@ -31,11 +31,11 @@ return {
config = true, -- run require("neorg").setup()
},
- -- or set a custom config:
+ -- or set custom options:
{
"nvim-neorg/neorg",
ft = "norg",
- config = { foo = "bar" }, -- run require("neorg").setup({foo = "bar"})
+ opts = { foo = "bar" }, -- run require("neorg").setup({foo = "bar"})
},
{
diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua
index 24b9de2..59fa139 100644
--- a/lua/lazy/health.lua
+++ b/lua/lazy/health.lua
@@ -68,8 +68,12 @@ function M.check_override(plugin)
return
end
+ local Handler = require("lazy.core.handler")
+ local skip = { "dependencies", "_", "opts" }
+ vim.list_extend(skip, vim.tbl_values(Handler.types))
+
for key, value in pairs(plugin._.super) do
- if key ~= "_" and plugin[key] and plugin[key] ~= value then
+ if not vim.tbl_contains(skip, key) and plugin[key] and plugin[key] ~= value then
vim.health.report_warn("{" .. plugin.name .. "}: overriding <" .. key .. ">")
end
end
@@ -77,29 +81,31 @@ end
M.valid = {
1,
- "name",
- "url",
- "enabled",
- "lazy",
- "dev",
- "dependencies",
- "init",
- "config",
- "build",
- "branch",
- "tag",
- "commit",
- "version",
- "module",
- "pin",
- "cmd",
- "event",
- "keys",
- "ft",
- "dir",
- "priority",
- "cond",
"_",
+ "branch",
+ "build",
+ "cmd",
+ "commit",
+ "cond",
+ "config",
+ "dependencies",
+ "dev",
+ "dir",
+ "enabled",
+ "event",
+ "ft",
+ "import",
+ "init",
+ "keys",
+ "lazy",
+ "module",
+ "name",
+ "opts",
+ "pin",
+ "priority",
+ "tag",
+ "url",
+ "version",
}
return M
diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua
index ab3832f..557a2f4 100644
--- a/lua/lazy/types.lua
+++ b/lua/lazy/types.lua
@@ -15,10 +15,13 @@
---@field cond? boolean
---@field super? LazyPlugin
+---@alias PluginOpts table|fun(self:LazyPlugin, opts:table):table?
+
---@class LazyPluginHooks
----@field init? fun(LazyPlugin) Will always be run
----@field config? fun(LazyPlugin)|true|table Will be executed when loading the plugin
----@field build? string|fun(LazyPlugin)|(string|fun(LazyPlugin))[]
+---@field init? fun(self:LazyPlugin) Will always be run
+---@field config? fun(self:LazyPlugin, opts:table)|true Will be executed when loading the plugin
+---@field build? string|fun(self:LazyPlugin)|(string|fun(self:LazyPlugin))[]
+---@field opts? PluginOpts
---@class LazyPluginHandlers
---@field event? string[]
diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua
index 7995381..d3b8902 100644
--- a/tests/core/plugin_spec.lua
+++ b/tests/core/plugin_spec.lua
@@ -1,5 +1,6 @@
local Config = require("lazy.core.config")
local Plugin = require("lazy.core.plugin")
+local Loader = require("lazy.core.loader")
local assert = require("luassert")
@@ -272,3 +273,37 @@ describe("plugin spec opt", function()
end
end)
end)
+
+describe("plugin opts", function()
+ it("correctly parses opts", function()
+ ---@type {spec:LazySpec, opts:table}[]
+ local tests = {
+ {
+ spec = { { "foo/foo", opts = { a = 1, b = 1 } }, { "foo/foo", opts = { a = 2 } } },
+ opts = { a = 2, b = 1 },
+ },
+ {
+ spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo", opts = { a = 2 } } },
+ opts = { a = 2, b = 1 },
+ },
+ {
+ spec = { { "foo/foo", opts = { a = 1, b = 1 } }, { "foo/foo", config = { a = 2 } } },
+ opts = { a = 2, b = 1 },
+ },
+ {
+ spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo", config = { a = 2 } } },
+ opts = { a = 2, b = 1 },
+ },
+ {
+ spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo", config = { a = vim.NIL } } },
+ opts = { b = 1 },
+ },
+ }
+
+ for _, test in ipairs(tests) do
+ local spec = Plugin.Spec.new(test.spec)
+ assert(spec.plugins.foo)
+ assert.same(test.opts, Loader.opts(spec.plugins.foo))
+ end
+ end)
+end)
From 2b1fccb817c41cc141ddb094244ac3849b45835b Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sun, 8 Jan 2023 14:02:50 +0000
Subject: [PATCH 037/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 73 ++++++++++++++++++++++++++++++-----------------
1 file changed, 47 insertions(+), 26 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 0ff1888..c9b3d98 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -111,30 +111,31 @@ It is recommended to run `:checkhealth lazy` after installation
PLUGIN SPEC *lazy.nvim-plugin-spec*
-│ Property │ Type │ Description │
-│[1] │string? │Short plugin url. Will be expanded using config.git.url_format │
-│**dir** │string? │A directory pointing to a local plugin │
-│**url** │string? │A custom git url where the plugin is hosted │
-│**name** │string? │A custom name for the plugin used for the local plugin directory and as the display name │
-│**dev** │boolean? │When true, a local plugin directory will be used instead. See config.dev │
-│**lazy** │boolean? │When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers │
-│**enabled** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be included in the spec │
-│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
-│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else.│
-│**init** │fun(LazyPlugin) │init functions are always executed during startup │
-│**config** │fun(LazyPlugin) or true or table │config is executed when the plugin loads. You can also set to true or pass a table, that will be passed to require("plugin").setup(opts) │
-│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
-│**branch** │string? │Branch of the repository │
-│**tag** │string? │Tag of the repository │
-│**commit** │string? │Commit of the repository │
-│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
-│**pin** │boolean? │When true, this plugin will not be included in updates │
-│**event** │string? or string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
-│**cmd** │string? or string[] │Lazy-load on command │
-│**ft** │string? or string[] │Lazy-load on filetype │
-│**keys** │string? or string[] or LazyKeys[] │Lazy-load on key mapping │
-│**module** │false? │Do not automatically load this Lua module when it’s required somewhere │
-│**priority** │number? │Only useful for **start** plugins (lazy=false) to force loading certain plugins first. Default priority is 50. It’s recommended to set this to a high number for colorschemes. │
+│ Property │ Type │ Description │
+│[1] │string? │Short plugin url. Will be expanded using config.git.url_format │
+│**dir** │string? │A directory pointing to a local plugin │
+│**url** │string? │A custom git url where the plugin is hosted │
+│**name** │string? │A custom name for the plugin used for the local plugin directory and as the display name │
+│**dev** │boolean? │When true, a local plugin directory will be used instead. See config.dev │
+│**lazy** │boolean? │When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers │
+│**enabled** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be included in the spec │
+│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
+│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
+│**init** │fun(LazyPlugin) │init functions are always executed during startup │
+│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. You can also set it to true, to automatically run require("plugin").setup(opts). See also opts. │
+│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
+│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
+│**branch** │string? │Branch of the repository │
+│**tag** │string? │Tag of the repository │
+│**commit** │string? │Commit of the repository │
+│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
+│**pin** │boolean? │When true, this plugin will not be included in updates │
+│**event** │string? or string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
+│**cmd** │string? or string[] │Lazy-load on command │
+│**ft** │string? or string[] │Lazy-load on filetype │
+│**keys** │string? or string[] or LazyKeys[] │Lazy-load on key mapping │
+│**module** │false? │Do not automatically load this Lua module when it’s required somewhere │
+│**priority** │number? │Only useful for **start** plugins (lazy=false) to force loading certain plugins first. Default priority is 50. It’s recommended to set this to a high number for colorschemes. │
LAZY LOADING ~
@@ -271,11 +272,11 @@ EXAMPLES ~
config = true, -- run require("neorg").setup()
},
- -- or set a custom config:
+ -- or set custom options:
{
"nvim-neorg/neorg",
ft = "norg",
- config = { foo = "bar" }, -- run require("neorg").setup({foo = "bar"})
+ opts = { foo = "bar" }, -- run require("neorg").setup({foo = "bar"})
},
{
@@ -724,6 +725,26 @@ For a real-life example, you can check LazyVim
- lazyvim.plugins contains all the plugin specs that will be loaded
+IMPORTING SPECS, `CONFIG` & `OPTS` ~
+
+As part of a spec, you can add `import` statements to import additional plugin
+modules. Both of the `setup()` calls are equivalent:
+
+>lua
+ require("lazy").setup("plugins")
+
+ -- same as:
+ require("lazy").setup({{import = "plugins"}})
+<
+
+
+When you import specs, you can override them by simply adding a spec for the
+same plugin to your local specs, adding any keys you want to override / merge.
+
+`opts`, `dependencies`, `cmd`, `event`, `ft` and `keys` are always merged with
+the parent spec. Any other property will override the property from the parent
+spec.
+
MIGRATION GUIDE *lazy.nvim-migration-guide*
PACKER.NVIM ~
From ef87c24e8ede2a94cbeaea1667eaeb7f8ed40dc0 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Sun, 8 Jan 2023 15:18:50 +0100
Subject: [PATCH 038/992] chore(main): release 9.0.0 (#350)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b02ae2f..212b4bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## [9.0.0](https://github.com/folke/lazy.nvim/compare/v8.1.0...v9.0.0) (2023-01-08)
+
+
+### ⚠ BREAKING CHANGES
+
+* **spec:** setting a table to `Plugin.config` is now deprecated. Please use `Plugin.opts` instead. (backward compatible for now)
+
+### Features
+
+* **git:** added fast `Git.get_origin` and `Git.get_config` ([a39fa0f](https://github.com/folke/lazy.nvim/commit/a39fa0f0ced7324800eff0a4eb0ed68bf13452d1))
+* **git:** lazy now detects origin changes and will fix it on update. Fixes [#346](https://github.com/folke/lazy.nvim/issues/346). Fixes [#331](https://github.com/folke/lazy.nvim/issues/331) ([615781a](https://github.com/folke/lazy.nvim/commit/615781aebfc0230669a2e5750cba3c65f0b8a90e))
+* **spec:** setting a table to `Plugin.config` is now deprecated. Please use `Plugin.opts` instead. (backward compatible for now) ([7260a2b](https://github.com/folke/lazy.nvim/commit/7260a2b28be807c4bdc1caf23fa35c2aa33aa6ac))
+* **util:** better deep merging with `Util.merge` ([6a31b97](https://github.com/folke/lazy.nvim/commit/6a31b97e3729af3710207642968e1492071a7dbc))
+
## [8.1.0](https://github.com/folke/lazy.nvim/compare/v8.0.0...v8.1.0) (2023-01-07)
From e77be3cf3b01402b86464e1734fb5ead448ce12e Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 8 Jan 2023 18:45:30 +0100
Subject: [PATCH 039/992] fix(spec): `Plugin.opts` is now always a table. Fixes
#351
---
lua/lazy/core/loader.lua | 7 ++-----
lua/lazy/core/util.lua | 3 +++
tests/core/plugin_spec.lua | 8 ++++++++
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 9054d32..1ed7361 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -234,6 +234,7 @@ end
-- Merges super opts or runs the opts function to override opts or return new ones
---@param plugin LazyPlugin
function M.opts(plugin)
+ ---@type table
local opts = plugin._.super and M.opts(plugin._.super) or {}
---@type PluginOpts?
local plugin_opts = rawget(plugin, "opts")
@@ -273,11 +274,7 @@ function M.config(plugin)
end
if #mods == 1 then
fn = function()
- local opts = M.opts(plugin)
- if next(opts) == nil then
- opts = nil
- end
- require(mods[1]).setup(opts)
+ require(mods[1]).setup(M.opts(plugin))
end
else
return Util.error(
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 70c1eb8..213a217 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -295,6 +295,9 @@ end
--- Values will me merged in-place in the first left-most table. If you want the result to be in
--- a new table, then simply pass an empty table as the first argument `vim.merge({}, ...)`
--- Supports clearing values by setting a key to `vim.NIL`
+---@generic T
+---@param ... T
+---@return T
function M.merge(...)
local values = { ... }
local ret = values[1]
diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua
index d3b8902..f7d39e2 100644
--- a/tests/core/plugin_spec.lua
+++ b/tests/core/plugin_spec.lua
@@ -298,6 +298,14 @@ describe("plugin opts", function()
spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo", config = { a = vim.NIL } } },
opts = { b = 1 },
},
+ {
+ spec = { { "foo/foo", config = { a = 1, b = 1 } }, { "foo/foo" } },
+ opts = { a = 1, b = 1 },
+ },
+ {
+ spec = { { "foo/foo" }, { "foo/foo" } },
+ opts = {},
+ },
}
for _, test in ipairs(tests) do
From a32e307981519a25dd3f05a33a6b7eea709f0fdc Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 9 Jan 2023 08:05:32 +0100
Subject: [PATCH 040/992] fix(diffview): fixed parameter for showing single
commit with DiffView. Fixes #304
---
lua/lazy/view/diff.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/view/diff.lua b/lua/lazy/view/diff.lua
index 24955b8..f4fe5af 100644
--- a/lua/lazy/view/diff.lua
+++ b/lua/lazy/view/diff.lua
@@ -25,7 +25,7 @@ M.handlers = {
["diffview.nvim"] = function(plugin, diff)
local args
if diff.commit then
- args = ("-C=%s"):format(plugin.dir) .. " " .. diff.commit
+ args = ("-C=%s"):format(plugin.dir) .. " " .. diff.commit .. "^!"
else
args = ("-C=%s"):format(plugin.dir) .. " " .. diff.from .. ".." .. diff.to
end
From 3a216d008def355813ede7deb5392276b7e3c10c Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 9 Jan 2023 08:05:46 +0100
Subject: [PATCH 041/992] fix(docs): auto-gen of readme stuff
---
lua/lazy/docs.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/docs.lua b/lua/lazy/docs.lua
index d274a57..118fcde 100644
--- a/lua/lazy/docs.lua
+++ b/lua/lazy/docs.lua
@@ -36,7 +36,7 @@ function M.save(contents)
if not readme:find(pattern) then
error("tag " .. tag .. " not found")
end
- if tag == "commands" or tag == "colors" or tag == "plugins" then
+ if tag == "commands" or tag == "colors" or tag == "plugins" or tag == "keymaps" then
readme = readme:gsub(pattern, "%1\n\n" .. content .. "\n\n%2")
else
readme = readme:gsub(pattern, "%1\n\n```lua\n" .. content .. "\n```\n\n%2")
@@ -137,7 +137,7 @@ end
function M.plugins()
local Config = require("lazy.core.config")
- local lines = { "## Plugins", "" }
+ local lines = {}
Util.foreach(Config.plugins, function(name, plugin)
if plugin.url then
lines[#lines + 1] = "- [" .. name .. "](" .. plugin.url:gsub("%.git$", "") .. ")"
From 55e86f855adfa259b751242da6c6cce2cebbbc7c Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 9 Jan 2023 07:06:45 +0000
Subject: [PATCH 042/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index c9b3d98..1c3dad8 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 08
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 09
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From d5345910a742f236d4c04273ed3956e543936022 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 9 Jan 2023 08:22:01 +0100
Subject: [PATCH 043/992] docs: clarified opts/config a bit
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 594b1ae..d2f1e49 100644
--- a/README.md
+++ b/README.md
@@ -91,8 +91,8 @@ require("lazy").setup({
| **cond** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. |
| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
-| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. You can also set it to `true`, to automatically run `require("plugin").setup(opts)`. See also `opts`. |
| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
+| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. See also `opts`. |
| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
| **branch** | `string?` | Branch of the repository |
| **tag** | `string?` | Tag of the repository |
From 1ca3f101c888b0cf5085bc12446061792e8ee024 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 9 Jan 2023 07:22:56 +0000
Subject: [PATCH 044/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 1c3dad8..4296883 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -122,8 +122,8 @@ PLUGIN SPEC *lazy.nvim-plugin-spec*
│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
│**init** │fun(LazyPlugin) │init functions are always executed during startup │
-│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. You can also set it to true, to automatically run require("plugin").setup(opts). See also opts. │
│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
+│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). See also opts. │
│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
│**branch** │string? │Branch of the repository │
│**tag** │string? │Tag of the repository │
From d813c518d54ced6e8c4c96931bf31329e258b791 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 9 Jan 2023 09:47:23 +0100
Subject: [PATCH 045/992] docs: improvements to readme updater
---
lua/lazy/docs.lua | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/lua/lazy/docs.lua b/lua/lazy/docs.lua
index 118fcde..44bddfa 100644
--- a/lua/lazy/docs.lua
+++ b/lua/lazy/docs.lua
@@ -25,25 +25,31 @@ function M.fix_indent(str)
return table.concat(lines, "\n")
end
----@param contents table
+---@alias ReadmeBlock {content:string, lang?:string}
+---@param contents table
function M.save(contents)
local readme = Util.read_file("README.md")
- for tag, content in pairs(contents) do
- content = M.fix_indent(content)
+ for tag, block in pairs(contents) do
+ if type(block) == "string" then
+ block = { content = block, lang = "lua" }
+ end
+ ---@cast block ReadmeBlock
+ local content = M.fix_indent(block.content)
content = content:gsub("%%", "%%%%")
content = vim.trim(content)
local pattern = "(<%!%-%- " .. tag .. ":start %-%->).*(<%!%-%- " .. tag .. ":end %-%->)"
if not readme:find(pattern) then
error("tag " .. tag .. " not found")
end
- if tag == "commands" or tag == "colors" or tag == "plugins" or tag == "keymaps" then
- readme = readme:gsub(pattern, "%1\n\n" .. content .. "\n\n%2")
+ if block.lang then
+ readme = readme:gsub(pattern, "%1\n\n```" .. block.lang .. "\n" .. content .. "\n```\n\n%2")
else
- readme = readme:gsub(pattern, "%1\n\n```lua\n" .. content .. "\n```\n\n%2")
+ readme = readme:gsub(pattern, "%1\n\n" .. content .. "\n\n%2")
end
end
Util.write_file("README.md", readme)
+ vim.cmd.checktime()
end
---@return string
@@ -52,6 +58,7 @@ function M.extract(file, pattern)
return assert(init:match(pattern))
end
+---@return ReadmeBlock
function M.commands()
local commands = require("lazy.view.commands").commands
local modes = require("lazy.view.config").commands
@@ -83,7 +90,7 @@ function M.commands()
end
end
end)
- return M.table(lines)
+ return { content = M.table(lines) }
end
---@param lines string[][]
@@ -96,6 +103,7 @@ function M.table(lines)
return table.concat(ret, "\n")
end
+---@return ReadmeBlock
function M.colors()
local str = M.extract("lua/lazy/view/colors.lua", "\nM%.colors = ({.-\n})")
---@type table
@@ -113,7 +121,7 @@ function M.colors()
Util.foreach(require("lazy.view.colors").colors, function(group, link)
lines[#lines + 1] = { "**Lazy" .. group .. "**", "***" .. link .. "***", comments[group] or "" }
end)
- return M.table(lines)
+ return { content = M.table(lines) }
end
function M.update()
@@ -132,18 +140,20 @@ function M.update()
commands = M.commands(),
colors = M.colors(),
})
- vim.cmd.checktime()
end
-function M.plugins()
- local Config = require("lazy.core.config")
+---@param plugins? LazyPlugin[]
+---@return ReadmeBlock
+function M.plugins(plugins)
+ plugins = plugins or require("lazy.core.config").plugins
+ ---@type string[]
local lines = {}
- Util.foreach(Config.plugins, function(name, plugin)
+ Util.foreach(plugins, function(name, plugin)
if plugin.url then
lines[#lines + 1] = "- [" .. name .. "](" .. plugin.url:gsub("%.git$", "") .. ")"
end
end)
- M.save({ plugins = table.concat(lines, "\n") })
+ return { content = table.concat(lines, "\n") }
end
return M
From 4304035ef4eae2d9dfac4fc082a1b391e6cd928e Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 9 Jan 2023 13:25:50 +0100
Subject: [PATCH 046/992] feat(spec): allow git@ and http urls in `Plugin[1]`
without `url=`. Fixes #357
---
lua/lazy/core/plugin.lua | 7 ++++++-
tests/core/plugin_spec.lua | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index d955b49..adaefae 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -52,7 +52,12 @@ function Spec:add(plugin, results, is_dep)
end
if not plugin.url and plugin[1] then
- plugin.url = Config.options.git.url_format:format(plugin[1])
+ local prefix = plugin[1]:sub(1, 4)
+ if prefix == "http" or prefix == "git@" then
+ plugin.url = plugin[1]
+ else
+ plugin.url = Config.options.git.url_format:format(plugin[1])
+ end
end
if plugin.dir then
diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua
index f7d39e2..ac8b3cb 100644
--- a/tests/core/plugin_spec.lua
+++ b/tests/core/plugin_spec.lua
@@ -11,6 +11,7 @@ describe("plugin spec url/name", function()
{ { dir = "~/foo" }, { name = "foo", dir = vim.fn.fnamemodify("~/foo", ":p") } },
{ { dir = "/tmp/foo" }, { dir = "/tmp/foo", name = "foo" } },
{ { "foo/bar" }, { [1] = "foo/bar", name = "bar", url = "https://github.com/foo/bar.git" } },
+ { { "https://foo.bar" }, { [1] = "https://foo.bar", name = "foo.bar", url = "https://foo.bar" } },
{ { "foo/bar", name = "foobar" }, { [1] = "foo/bar", name = "foobar", url = "https://github.com/foo/bar.git" } },
{ { "foo/bar", url = "123" }, { [1] = "foo/bar", name = "123", url = "123" } },
{ { url = "https://foobar" }, { name = "foobar", url = "https://foobar" } },
From e6ee0fa6103e9514e85a96fc16902ad7f777b53f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 9 Jan 2023 20:21:31 +0100
Subject: [PATCH 047/992] fix(ui): keymap for building a single plugin changed
from `b` to `gb`. Fixes #358
---
lua/lazy/view/config.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/view/config.lua b/lua/lazy/view/config.lua
index b75c0f5..1f38540 100644
--- a/lua/lazy/view/config.lua
+++ b/lua/lazy/view/config.lua
@@ -144,7 +144,7 @@ M.commands = {
id = 13,
plugins = true,
plugins_required = true,
- key_plugin = "b",
+ key_plugin = "gb",
},
}
From b28c6b900030556e4e72f2ce68abae0e7292a3bf Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 10 Jan 2023 07:32:28 +0100
Subject: [PATCH 048/992] feat(util): `Util.merge` now support advanced merging
strategies. Docs coming soon
---
TODO.md | 5 +++++
lua/lazy/core/plugin.lua | 16 +++-------------
lua/lazy/core/util.lua | 31 +++++++++++++++++++++++++++++-
tests/core/util_spec.lua | 41 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+), 14 deletions(-)
diff --git a/TODO.md b/TODO.md
index 5ad36cb..59607a5 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,5 +1,10 @@
# ✅ TODO
+- [ ] better merging options?
+- [ ] especially what to do with merging of handlers?
+- [ ] overwriting keymaps probably doesn't work
+- [ ] disabled deps?
+
- [x] fancy UI to manage all your Neovim plugins
- [x] auto lazy-loading of lua modules
- [x] lazy-loading on events, commands, filetypes and key mappings
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index adaefae..8156240 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -270,20 +270,10 @@ function Spec:merge(old, new)
for _, prop in ipairs(list_merge) do
if new[prop] and old[prop] then
- ---@type any[]
- local props = {}
- ---@diagnostic disable-next-line: no-unknown
- for _, value in ipairs(old[prop]) do
- props[#props + 1] = value
+ if new[prop].__merge == nil then
+ new[prop].__merge = true
end
- ---@diagnostic disable-next-line: no-unknown
- for _, value in ipairs(new[prop]) do
- if not vim.tbl_contains(props, value) then
- props[#props + 1] = value
- end
- end
- ---@diagnostic disable-next-line: no-unknown
- new[prop] = props
+ new[prop] = Util.merge(old[prop], new[prop])
end
end
new._.super = old
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 213a217..981ad34 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -286,10 +286,27 @@ function M.debug(msg, level, opts)
end
end
+local MERGE = "__merge"
+
local function can_merge(v)
return type(v) == "table" and (vim.tbl_isempty(v) or not M.is_list(v))
end
+local function can_extend(v)
+ return type(v) == "table" and (vim.tbl_isempty(v) or M.is_list(v))
+end
+
+---@param v any|{__merge:boolean}
+---@param merge? boolean
+---@return boolean?
+local function check_merge(v, merge)
+ if type(v) == "table" and v[MERGE] ~= nil then
+ merge = v[MERGE]
+ v[MERGE] = nil
+ end
+ return merge
+end
+
--- Merges the values similar to vim.tbl_deep_extend with the **force** behavior,
--- but the values can be any type, in which case they override the values on the left.
--- Values will me merged in-place in the first left-most table. If you want the result to be in
@@ -301,12 +318,24 @@ end
function M.merge(...)
local values = { ... }
local ret = values[1]
+
+ if ret == vim.NIL then
+ ret = nil
+ end
+
+ local merge = check_merge(ret)
+
for i = 2, #values, 1 do
local value = values[i]
- if can_merge(ret) and can_merge(value) then
+ merge = check_merge(value, merge)
+ if can_merge(ret) and can_merge(value) and merge ~= false then
for k, v in pairs(value) do
ret[k] = M.merge(ret[k], v)
end
+ elseif can_extend(ret) and can_extend(value) and merge then
+ for _, v in ipairs(value) do
+ ret[#ret + 1] = v
+ end
elseif value == vim.NIL then
ret = nil
else
diff --git a/tests/core/util_spec.lua b/tests/core/util_spec.lua
index 7349c68..7d16ca6 100644
--- a/tests/core/util_spec.lua
+++ b/tests/core/util_spec.lua
@@ -132,4 +132,45 @@ describe("util", function()
assert(root, "foobar root not found")
assert.same(Helpers.path("new/lua/foobar"), root)
end)
+
+ it("merges correctly", function()
+ local tests = {
+ {
+ input = { { a = 1 }, { b = 2 } },
+ output = { a = 1, b = 2 },
+ },
+ {
+ input = { { a = 1 }, { a = 2 } },
+ output = { a = 2 },
+ },
+ {
+ input = { { a = { 1, 2 } }, { a = { 3 } } },
+ output = { a = { 3 } },
+ },
+ {
+ input = { { b = { 1, 2 } }, { a = { 3 }, __merge = false } },
+ output = { a = { 3 } },
+ },
+ {
+ input = { { a = 1 }, { b = 2, __merge = false } },
+ output = { b = 2 },
+ },
+ {
+ input = { { a = { 1, 2 } }, { a = { 3, __merge = true } } },
+ output = { a = { 1, 2, 3 } },
+ },
+ {
+ input = { { a = { 1, 2, __merge = true } }, { a = { 3 } } },
+ output = { a = { 1, 2, 3 } },
+ },
+ {
+ input = { { a = { 1, 2, __merge = true } }, { a = { 3, __merge = false } } },
+ output = { a = { 3 } },
+ },
+ }
+
+ for _, test in ipairs(tests) do
+ assert.same(test.output, Util.merge(unpack(test.input)))
+ end
+ end)
end)
From 1f17bb79b77882118db1b7913e7f1a89c9734433 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Tue, 10 Jan 2023 06:33:21 +0000
Subject: [PATCH 049/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 4296883..618d3e0 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 09
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 10
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From d3a963d51c0b5419a1fd84774b24d35a3e6c8996 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 10 Jan 2023 08:42:20 +0100
Subject: [PATCH 050/992] refactor(util): improved notify functions
---
lua/lazy/core/cache.lua | 13 +++++------
lua/lazy/core/plugin.lua | 2 +-
lua/lazy/core/util.lua | 48 +++++++++++++++++++++++++---------------
3 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 09792bc..e99f79e 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -105,25 +105,24 @@ function M.disable()
_G.loadfile = M._loadfile
M.enabled = false
if M.debug and vim.tbl_count(M.topmods) > 1 then
- M.log(M.topmods, vim.log.levels.WARN, { title = "topmods" })
+ M.log(M.topmods, { level = vim.log.levels.WARN, title = "topmods" })
end
if M.debug and false then
local stats = vim.deepcopy(M.stats)
stats.time = (stats.time or 0) / 1e6
stats.find.time = (stats.find.time or 0) / 1e6
stats.autoload.time = (stats.autoload.time or 0) / 1e6
- M.log(stats, nil, { title = "stats" })
+ M.log(stats, { title = "stats" })
end
end
---@param msg string|table
----@param level? number
----@param opts? {lang:string, title:string}
-function M.log(msg, level, opts)
+---@param opts? LazyNotifyOpts
+function M.log(msg, opts)
if M.debug then
msg = vim.deepcopy(msg)
vim.schedule(function()
- require("lazy.core.util").debug(msg, level, opts)
+ require("lazy.core.util").debug(msg, opts)
end)
end
end
@@ -208,7 +207,7 @@ function M.load(modkey, modpath)
entry.hash = hash
if M.debug then
- M.log("`" .. modpath .. "`", vim.log.levels.WARN, { title = "Cache.load" })
+ M.log("`" .. modpath .. "`", { level = vim.log.levels.WARN, title = "Cache.load" })
end
chunk, err = M._loadfile(entry.modpath)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index 8156240..135bdd6 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -180,7 +180,7 @@ function Spec:report(level)
level = level or vim.log.levels.ERROR
for _, notif in ipairs(self.notifs) do
if notif.level >= level then
- Util.notify(notif.msg, notif.level)
+ Util.notify(notif.msg, { level = notif.level })
end
end
end
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 981ad34..b3a9811 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -219,14 +219,15 @@ function M.lsmod(modname, fn)
end)
end
+---@alias LazyNotifyOpts {lang?:string, title?:string, level?:number}
+
---@param msg string|string[]
----@param opts? {lang:string, title:string}
-function M.notify(msg, level, opts)
+---@param opts? LazyNotifyOpts
+function M.notify(msg, opts)
if vim.in_fast_event() then
- vim.schedule(function()
- M.notify(msg, level, opts)
+ return vim.schedule(function()
+ M.notify(msg, opts)
end)
- return
end
opts = opts or {}
@@ -239,7 +240,7 @@ function M.notify(msg, level, opts)
)
end
local lang = opts.lang or "markdown"
- vim.notify(msg, level, {
+ vim.notify(msg, opts.level or vim.log.levels.INFO, {
on_open = function(win)
pcall(require, "nvim-treesitter")
vim.wo[win].conceallevel = 3
@@ -251,38 +252,49 @@ function M.notify(msg, level, opts)
vim.bo[buf].syntax = lang
end
end,
- title = "lazy.nvim" .. (opts.title and ": " .. opts.title or ""),
+ title = opts.title or "lazy.nvim",
})
end
---@param msg string|string[]
-function M.error(msg)
- M.notify(msg, vim.log.levels.ERROR)
+---@param opts? LazyNotifyOpts
+function M.error(msg, opts)
+ opts = opts or {}
+ opts.level = vim.log.levels.ERROR
+ M.notify(msg, opts)
end
---@param msg string|string[]
-function M.info(msg)
- M.notify(msg, vim.log.levels.INFO)
+---@param opts? LazyNotifyOpts
+function M.info(msg, opts)
+ opts = opts or {}
+ opts.level = vim.log.levels.INFO
+ M.notify(msg, opts)
end
---@param msg string|string[]
-function M.warn(msg)
- M.notify(msg, vim.log.levels.WARN)
+---@param opts? LazyNotifyOpts
+function M.warn(msg, opts)
+ opts = opts or {}
+ opts.level = vim.log.levels.WARN
+ M.notify(msg, opts)
end
---@param msg string|table
----@param level? number
----@param opts? {lang:string, title:string}
-function M.debug(msg, level, opts)
+---@param opts? LazyNotifyOpts
+function M.debug(msg, opts)
if not require("lazy.core.config").options.debug then
return
end
opts = opts or {}
+ if opts.title then
+ opts.title = "lazy.nvim: " .. opts.title
+ end
if type(msg) == "string" then
- M.notify(msg, level, opts)
+ M.notify(msg, opts)
else
opts.lang = "lua"
- M.notify(vim.inspect(msg), level, opts)
+ M.notify(vim.inspect(msg), opts)
end
end
From 9fa62ea8ea935dec7078587c3664047db2065bf2 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 10 Jan 2023 08:42:51 +0100
Subject: [PATCH 051/992] fix(cache): dont keep invalid entries in the cache
(cleanup)
---
lua/lazy/core/cache.lua | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index e99f79e..4d5058a 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -144,9 +144,14 @@ function M.loader(modname)
local entry = M.cache[modname]
local chunk, err
- if entry and M.check_path(modname, entry.modpath) then
- M.stats.find.total = M.stats.find.total + 1
- chunk, err = M.load(modname, entry.modpath)
+ if entry then
+ if M.check_path(modname, entry.modpath) then
+ M.stats.find.total = M.stats.find.total + 1
+ chunk, err = M.load(modname, entry.modpath)
+ else
+ M.cache[modname] = nil
+ M.dirty = true
+ end
end
if not chunk then
-- find the modpath and load the module
From ad7aafb257516cefff85aceb5d36041090b40559 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 10 Jan 2023 09:20:39 +0100
Subject: [PATCH 052/992] fix(spec): don't import specs more than once
---
lua/lazy/core/plugin.lua | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index 135bdd6..bdba503 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -225,6 +225,9 @@ function Spec:import(spec)
if spec.import == "lazy" then
return self:error("You can't name your plugins module `lazy`.")
end
+ if vim.tbl_contains(self.modules, spec.import) then
+ return
+ end
if spec.enabled == false or (type(spec.enabled) == "function" and not spec.enabled()) then
return
end
@@ -278,6 +281,7 @@ function Spec:merge(old, new)
end
new._.super = old
setmetatable(new, { __index = old })
+
return new
end
From 70b07ebad5061010290e4b47cee3b2ba2277fe73 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 10 Jan 2023 09:28:54 +0100
Subject: [PATCH 053/992] ci: let release-please update Config.version
---
.github/workflows/ci.yml | 2 ++
lua/lazy/core/config.lua | 2 ++
2 files changed, 4 insertions(+)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2adb58f..8046e5a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -55,6 +55,8 @@ jobs:
with:
release-type: simple
package-name: lazy.nvim
+ extra-files: |
+ lua/lazy/core/config.lua
- uses: actions/checkout@v2
- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 372bc70..ed010b9 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,6 +139,8 @@ M.defaults = {
debug = false,
}
+M.version = "9.0.0" -- x-release-please-version
+
M.ns = vim.api.nvim_create_namespace("lazy")
---@type LazySpecLoader
From 18eb724dffd613b1c2bde45f86aa05a5477ce80b Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 10 Jan 2023 09:40:28 +0100
Subject: [PATCH 054/992] chore(main): release 9.1.0 (#352)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 18 ++++++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 212b4bd..9663cf1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,23 @@
# Changelog
+## [9.1.0](https://github.com/folke/lazy.nvim/compare/v9.0.0...v9.1.0) (2023-01-10)
+
+
+### Features
+
+* **spec:** allow git@ and http urls in `Plugin[1]` without `url=`. Fixes [#357](https://github.com/folke/lazy.nvim/issues/357) ([4304035](https://github.com/folke/lazy.nvim/commit/4304035ef4eae2d9dfac4fc082a1b391e6cd928e))
+* **util:** `Util.merge` now support advanced merging strategies. Docs coming soon ([b28c6b9](https://github.com/folke/lazy.nvim/commit/b28c6b900030556e4e72f2ce68abae0e7292a3bf))
+
+
+### Bug Fixes
+
+* **cache:** dont keep invalid entries in the cache (cleanup) ([9fa62ea](https://github.com/folke/lazy.nvim/commit/9fa62ea8ea935dec7078587c3664047db2065bf2))
+* **diffview:** fixed parameter for showing single commit with DiffView. Fixes [#304](https://github.com/folke/lazy.nvim/issues/304) ([a32e307](https://github.com/folke/lazy.nvim/commit/a32e307981519a25dd3f05a33a6b7eea709f0fdc))
+* **docs:** auto-gen of readme stuff ([3a216d0](https://github.com/folke/lazy.nvim/commit/3a216d008def355813ede7deb5392276b7e3c10c))
+* **spec:** `Plugin.opts` is now always a table. Fixes [#351](https://github.com/folke/lazy.nvim/issues/351) ([e77be3c](https://github.com/folke/lazy.nvim/commit/e77be3cf3b01402b86464e1734fb5ead448ce12e))
+* **spec:** don't import specs more than once ([ad7aafb](https://github.com/folke/lazy.nvim/commit/ad7aafb257516cefff85aceb5d36041090b40559))
+* **ui:** keymap for building a single plugin changed from `b` to `gb`. Fixes [#358](https://github.com/folke/lazy.nvim/issues/358) ([e6ee0fa](https://github.com/folke/lazy.nvim/commit/e6ee0fa6103e9514e85a96fc16902ad7f777b53f))
+
## [9.0.0](https://github.com/folke/lazy.nvim/compare/v8.1.0...v9.0.0) (2023-01-08)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index ed010b9..69ff4d1 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,7 +139,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.0.0" -- x-release-please-version
+M.version = "9.1.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 5faadf6398f99f781a212d2a7cbd39a688d32300 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 10 Jan 2023 11:19:47 +0100
Subject: [PATCH 055/992] fix(ui): get_plugin should return when ui is not
showing
---
lua/lazy/view/render.lua | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index fd4b138..1c0bd3c 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -91,6 +91,9 @@ end
---@param row? number
---@return LazyPlugin?
function M:get_plugin(row)
+ if not (self.view.win and vim.api.nvim_win_is_valid(self.view.win)) then
+ return
+ end
row = row or vim.api.nvim_win_get_cursor(self.view.win)[1]
for _, loc in ipairs(self.locations) do
if row >= loc.from and row <= loc.to then
From d2110278be136fd977d357ff49689352d58b2e83 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 10 Jan 2023 11:21:52 +0100
Subject: [PATCH 056/992] chore(main): release 9.1.1 (#360)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 7 +++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9663cf1..e6db6e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## [9.1.1](https://github.com/folke/lazy.nvim/compare/v9.1.0...v9.1.1) (2023-01-10)
+
+
+### Bug Fixes
+
+* **ui:** get_plugin should return when ui is not showing ([5faadf6](https://github.com/folke/lazy.nvim/commit/5faadf6398f99f781a212d2a7cbd39a688d32300))
+
## [9.1.0](https://github.com/folke/lazy.nvim/compare/v9.0.0...v9.1.0) (2023-01-10)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 69ff4d1..720b4ce 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,7 +139,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.1.0" -- x-release-please-version
+M.version = "9.1.1" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 8756c0950ca9053713262abd1092f6d100adc9a5 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 10 Jan 2023 14:26:28 +0100
Subject: [PATCH 057/992] fix(ui): properly position Lazy tabs when opening
another cmd. Fixes #361
---
lua/lazy/util.lua | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua
index 8e8a638..846c6d0 100644
--- a/lua/lazy/util.lua
+++ b/lua/lazy/util.lua
@@ -8,14 +8,28 @@ end
---@param opts? LazyFloatOptions
function M.float(opts)
opts = opts or {}
- if require("lazy.view").visible() then
+ local cursor
+ local View = require("lazy.view")
+ if View.visible() then
+ -- set cursor to the top of the ui, so the tabs are visible
+ cursor = vim.api.nvim_win_get_cursor(View.view.win)
+ vim.api.nvim_win_set_cursor(View.view.win, { 1, 0 })
opts = vim.tbl_deep_extend("force", {
zindex = 60,
border = "none",
margin = { top = 3, left = 2, right = 2 },
}, opts)
end
- return require("lazy.view.float")(opts)
+ local ret = require("lazy.view.float")(opts)
+ -- restore the cursor
+ if cursor then
+ ret:on("BufLeave", function()
+ if View.visible() then
+ vim.api.nvim_win_set_cursor(View.view.win, cursor)
+ end
+ end, { once = true })
+ end
+ return ret
end
function M.open(uri)
From 5aca9280df4245df8bf8e33fe9bc4ce85507dc31 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 11 Jan 2023 13:40:19 +0100
Subject: [PATCH 058/992] perf(util): execute VeryLazy right after UIEnter
---
lua/lazy/core/util.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index b3a9811..c13d7fe 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -141,10 +141,10 @@ end
function M.very_lazy()
local function _load()
- vim.defer_fn(function()
+ vim.schedule(function()
vim.g.did_very_lazy = true
vim.cmd("do User VeryLazy")
- end, 50)
+ end)
end
vim.api.nvim_create_autocmd("User", {
@@ -154,7 +154,7 @@ function M.very_lazy()
if vim.v.vim_did_enter == 1 then
_load()
else
- vim.api.nvim_create_autocmd("VimEnter", {
+ vim.api.nvim_create_autocmd("UIEnter", {
once = true,
callback = function()
_load()
From 3b44c3c14ad69e7a26ae6408816f332af58202c3 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 11 Jan 2023 13:43:17 +0100
Subject: [PATCH 059/992] fix(ui): reset buf and win options on resize
---
lua/lazy/view/float.lua | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index 6b22052..a4a05b0 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -103,11 +103,15 @@ function M:mount()
if vim.bo[self.buf].filetype == "" then
vim.bo[self.buf].filetype = "lazy"
end
- vim.bo[self.buf].bufhidden = "wipe"
- vim.wo[self.win].conceallevel = 3
- vim.wo[self.win].spell = false
- vim.wo[self.win].wrap = true
- vim.wo[self.win].winhighlight = "Normal:LazyNormal"
+
+ local function opts()
+ vim.bo[self.buf].bufhidden = "wipe"
+ vim.wo[self.win].conceallevel = 3
+ vim.wo[self.win].spell = false
+ vim.wo[self.win].wrap = true
+ vim.wo[self.win].winhighlight = "Normal:LazyNormal"
+ end
+ opts()
vim.api.nvim_create_autocmd("VimResized", {
callback = function()
@@ -120,7 +124,9 @@ function M:mount()
---@diagnostic disable-next-line: no-unknown
config[key] = self.win_opts[key]
end
+ config.style = self.opts.style ~= "" and self.opts.style or nil
vim.api.nvim_win_set_config(self.win, config)
+ opts()
vim.cmd([[do User LazyFloatResized]])
end,
})
From 74bc61ab97c3bc2e73e19d269f23076d50c3285f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 11 Jan 2023 13:43:57 +0100
Subject: [PATCH 060/992] fix(handlers): allow overriding handler values
---
lua/lazy/core/handler/init.lua | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lua/lazy/core/handler/init.lua b/lua/lazy/core/handler/init.lua
index 0935f51..67ad44c 100644
--- a/lua/lazy/core/handler/init.lua
+++ b/lua/lazy/core/handler/init.lua
@@ -77,8 +77,13 @@ end
---@param plugin LazyPlugin
function M:add(plugin)
+ local values = {}
for _, value in ipairs(plugin[self.type] or {}) do
local key = self:key(value)
+ values[key] = value
+ end
+
+ for key, value in pairs(values) do
if not self.active[key] then
self.active[key] = {}
self:_add(value)
@@ -89,7 +94,13 @@ end
---@param plugin LazyPlugin
function M:del(plugin)
+ local values = {}
for _, value in ipairs(plugin[self.type] or {}) do
+ local key = self:key(value)
+ values[key] = value
+ end
+
+ for key, value in pairs(values) do
local key = self:key(value)
if self.active[key] and self.active[key][plugin.name] then
self.active[key][plugin.name] = nil
From 41c7a6a6c0569280e88f9d264c2734fbdacbe433 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 11 Jan 2023 12:45:07 +0000
Subject: [PATCH 061/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 618d3e0..584c2c2 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 10
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 11
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From a64623899db9fe1a41c8bf86562feed6d4757ba0 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 11 Jan 2023 17:13:03 +0100
Subject: [PATCH 062/992] fix(ui): possible error during initial install
---
TODO.md | 5 +++++
lua/lazy/view/float.lua | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/TODO.md b/TODO.md
index 59607a5..d3d2f09 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,5 +1,10 @@
# ✅ TODO
+- [x] progress bar?
+- [x] options when opening file
+- [x] lazy notify? not ideal when installing missing stuff
+- [x] topmods?
+
- [ ] better merging options?
- [ ] especially what to do with merging of handlers?
- [ ] overwriting keymaps probably doesn't work
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index a4a05b0..d6e3c39 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -115,7 +115,7 @@ function M:mount()
vim.api.nvim_create_autocmd("VimResized", {
callback = function()
- if not self.win then
+ if not (self.win and vim.api.nvim_win_is_valid(self.win)) then
return true
end
self:layout()
From 9d494e05943995f8836cefd22b709920af36665b Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 11 Jan 2023 21:45:02 +0100
Subject: [PATCH 063/992] chore(main): release 9.1.2 (#362)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 15 +++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6db6e8..4d9de10 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,20 @@
# Changelog
+## [9.1.2](https://github.com/folke/lazy.nvim/compare/v9.1.1...v9.1.2) (2023-01-11)
+
+
+### Bug Fixes
+
+* **handlers:** allow overriding handler values ([74bc61a](https://github.com/folke/lazy.nvim/commit/74bc61ab97c3bc2e73e19d269f23076d50c3285f))
+* **ui:** possible error during initial install ([a646238](https://github.com/folke/lazy.nvim/commit/a64623899db9fe1a41c8bf86562feed6d4757ba0))
+* **ui:** properly position Lazy tabs when opening another cmd. Fixes [#361](https://github.com/folke/lazy.nvim/issues/361) ([8756c09](https://github.com/folke/lazy.nvim/commit/8756c0950ca9053713262abd1092f6d100adc9a5))
+* **ui:** reset buf and win options on resize ([3b44c3c](https://github.com/folke/lazy.nvim/commit/3b44c3c14ad69e7a26ae6408816f332af58202c3))
+
+
+### Performance Improvements
+
+* **util:** execute VeryLazy right after UIEnter ([5aca928](https://github.com/folke/lazy.nvim/commit/5aca9280df4245df8bf8e33fe9bc4ce85507dc31))
+
## [9.1.1](https://github.com/folke/lazy.nvim/compare/v9.1.0...v9.1.1) (2023-01-10)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 720b4ce..410f06e 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,7 +139,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.1.1" -- x-release-please-version
+M.version = "9.1.2" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From e1cd9cd0adfb04432ffaf3d8bd54a5b409eb4273 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 11 Jan 2023 23:07:58 +0100
Subject: [PATCH 064/992] fix(loader): prevent loading plugins when loading
specs
---
lua/lazy/core/cache.lua | 14 ++++++--------
lua/lazy/core/plugin.lua | 3 +++
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 4d5058a..5bd370a 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -72,23 +72,21 @@ end
function M.check_autoload(modname, modpath)
local start = uv.hrtime()
M.stats.autoload.total = M.stats.autoload.total + 1
+
-- check plugins. Again fast, since we check the plugin name from the path.
-- only needed when the plugin mod has been loaded
---@type LazyCorePlugin
local Plugin = package.loaded["lazy.core.plugin"]
- if Plugin then
+ if Plugin and not Plugin.loading then
local plugin = Plugin.find(modpath)
if plugin and modpath:find(plugin.dir, 1, true) == 1 then
-- we're not interested in loader time, so calculate delta here
M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start
- -- only autoload when plugins have been loaded
- if not vim.tbl_isempty(require("lazy.core.config").plugins) then
- if not plugin._.loaded then
- if plugin.module == false then
- error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
- end
- require("lazy.core.loader").load(plugin, { require = modname })
+ if not plugin._.loaded then
+ if plugin.module == false then
+ error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
end
+ require("lazy.core.loader").load(plugin, { require = modname })
end
return true
end
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index bdba503..88713e4 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -5,6 +5,7 @@ local Cache = require("lazy.core.cache")
---@class LazyCorePlugin
local M = {}
+M.loading = false
local list_merge = { "dependencies" }
vim.list_extend(list_merge, vim.tbl_values(Handler.types))
@@ -330,6 +331,7 @@ function M.update_state()
end
function M.load()
+ M.loading = true
-- load specs
Util.track("spec")
Config.spec = Spec.new()
@@ -363,6 +365,7 @@ function M.load()
M.update_state()
Util.track()
require("lazy.core.cache").indexed_unloaded = false
+ M.loading = false
end
-- Finds the plugin that has this path
From 07fd7adb3427ac510c33de308cd5dfcc6ba701b6 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 11 Jan 2023 23:11:38 +0100
Subject: [PATCH 065/992] fix(cache): use cached chunk when specs are loading
for valid plugins
---
lua/lazy/core/cache.lua | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 5bd370a..bad46ab 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -77,12 +77,13 @@ function M.check_autoload(modname, modpath)
-- only needed when the plugin mod has been loaded
---@type LazyCorePlugin
local Plugin = package.loaded["lazy.core.plugin"]
- if Plugin and not Plugin.loading then
+ if Plugin then
local plugin = Plugin.find(modpath)
if plugin and modpath:find(plugin.dir, 1, true) == 1 then
-- we're not interested in loader time, so calculate delta here
M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start
- if not plugin._.loaded then
+ -- don't load if we're loading specs or if the plugin is already loaded
+ if not (Plugin.loading or plugin._.loaded) then
if plugin.module == false then
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
end
From 0741d6231917ef77cd5f69a9b1aacc402a676dd1 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 11 Jan 2023 23:13:41 +0100
Subject: [PATCH 066/992] chore(main): release 9.1.3 (#374)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 8 ++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d9de10..c80a637 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## [9.1.3](https://github.com/folke/lazy.nvim/compare/v9.1.2...v9.1.3) (2023-01-11)
+
+
+### Bug Fixes
+
+* **cache:** use cached chunk when specs are loading for valid plugins ([07fd7ad](https://github.com/folke/lazy.nvim/commit/07fd7adb3427ac510c33de308cd5dfcc6ba701b6))
+* **loader:** prevent loading plugins when loading specs ([e1cd9cd](https://github.com/folke/lazy.nvim/commit/e1cd9cd0adfb04432ffaf3d8bd54a5b409eb4273))
+
## [9.1.2](https://github.com/folke/lazy.nvim/compare/v9.1.1...v9.1.2) (2023-01-11)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 410f06e..97cc131 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,7 +139,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.1.2" -- x-release-please-version
+M.version = "9.1.3" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 3fbe4fe27ab6b58e5dafd45c5316ec62791907d4 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 12 Jan 2023 09:01:29 +0100
Subject: [PATCH 067/992] fix(ui): open diff and others over the ui. Don't try
to be smart about it. Fixes #361
---
lua/lazy/util.lua | 24 +-----------------------
1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua
index 846c6d0..456ad83 100644
--- a/lua/lazy/util.lua
+++ b/lua/lazy/util.lua
@@ -7,29 +7,7 @@ end
---@param opts? LazyFloatOptions
function M.float(opts)
- opts = opts or {}
- local cursor
- local View = require("lazy.view")
- if View.visible() then
- -- set cursor to the top of the ui, so the tabs are visible
- cursor = vim.api.nvim_win_get_cursor(View.view.win)
- vim.api.nvim_win_set_cursor(View.view.win, { 1, 0 })
- opts = vim.tbl_deep_extend("force", {
- zindex = 60,
- border = "none",
- margin = { top = 3, left = 2, right = 2 },
- }, opts)
- end
- local ret = require("lazy.view.float")(opts)
- -- restore the cursor
- if cursor then
- ret:on("BufLeave", function()
- if View.visible() then
- vim.api.nvim_win_set_cursor(View.view.win, cursor)
- end
- end, { once = true })
- end
- return ret
+ return require("lazy.view.float")(opts)
end
function M.open(uri)
From bcd87a02150d68d2ee187e61b97585e1b33110ce Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 12 Jan 2023 08:02:16 +0000
Subject: [PATCH 068/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 584c2c2..5a9c935 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 11
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 12
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 2128ca90fb67928e5e23590142de9c94fc0a0d31 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 12 Jan 2023 13:07:51 +0100
Subject: [PATCH 069/992] feat(spec): event, keys, ft and cmd can now also be a
function that returns the values to be used
---
README.md | 52 ++++++++++++++++----------------
lua/lazy/core/cache.lua | 2 +-
lua/lazy/core/loader.lua | 25 ++--------------
lua/lazy/core/plugin.lua | 61 +++++++++++++++++++++++++-------------
lua/lazy/types.lua | 10 +++----
tests/core/plugin_spec.lua | 1 -
6 files changed, 76 insertions(+), 75 deletions(-)
diff --git a/README.md b/README.md
index d2f1e49..e568d31 100644
--- a/README.md
+++ b/README.md
@@ -79,32 +79,32 @@ require("lazy").setup({
## 🔌 Plugin Spec
-| Property | Type | Description |
-| ---------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `[1]` | `string?` | Short plugin url. Will be expanded using `config.git.url_format` |
-| **dir** | `string?` | A directory pointing to a local plugin |
-| **url** | `string?` | A custom git url where the plugin is hosted |
-| **name** | `string?` | A custom name for the plugin used for the local plugin directory and as the display name |
-| **dev** | `boolean?` | When `true`, a local plugin directory will be used instead. See `config.dev` |
-| **lazy** | `boolean?` | When `true`, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are `required`, or when one of the lazy-loading handlers triggers |
-| **enabled** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be included in the spec |
-| **cond** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. |
-| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
-| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
-| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
-| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. See also `opts`. |
-| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
-| **branch** | `string?` | Branch of the repository |
-| **tag** | `string?` | Tag of the repository |
-| **commit** | `string?` | Commit of the repository |
-| **version** | `string?` | Version to use from the repository. Full [Semver](https://devhints.io/semver) ranges are supported |
-| **pin** | `boolean?` | When `true`, this plugin will not be included in updates |
-| **event** | `string?` or `string[]` | Lazy-load on event. Events can be specified as `BufEnter` or with a pattern like `BufEnter *.lua` |
-| **cmd** | `string?` or `string[]` | Lazy-load on command |
-| **ft** | `string?` or `string[]` | Lazy-load on filetype |
-| **keys** | `string?` or `string[]` or `LazyKeys[]` | Lazy-load on key mapping |
-| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
-| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
+| Property | Type | Description |
+| ---------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `[1]` | `string?` | Short plugin url. Will be expanded using `config.git.url_format` |
+| **dir** | `string?` | A directory pointing to a local plugin |
+| **url** | `string?` | A custom git url where the plugin is hosted |
+| **name** | `string?` | A custom name for the plugin used for the local plugin directory and as the display name |
+| **dev** | `boolean?` | When `true`, a local plugin directory will be used instead. See `config.dev` |
+| **lazy** | `boolean?` | When `true`, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are `required`, or when one of the lazy-loading handlers triggers |
+| **enabled** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be included in the spec |
+| **cond** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. |
+| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
+| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
+| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
+| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. See also `opts`. |
+| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
+| **branch** | `string?` | Branch of the repository |
+| **tag** | `string?` | Tag of the repository |
+| **commit** | `string?` | Commit of the repository |
+| **version** | `string?` | Version to use from the repository. Full [Semver](https://devhints.io/semver) ranges are supported |
+| **pin** | `boolean?` | When `true`, this plugin will not be included in updates |
+| **event** | `string?` or `string[]` or `fun(self:LazyPlugin, event:string[]):string[]` | Lazy-load on event. Events can be specified as `BufEnter` or with a pattern like `BufEnter *.lua` |
+| **cmd** | `string?` or `string[]` or `fun(self:LazyPlugin, cmd:string[]):string[]` | Lazy-load on command |
+| **ft** | `string?` or `string[]` or `fun(self:LazyPlugin, ft:string[]):string[]` | Lazy-load on filetype |
+| **keys** | `string?` or `string[]` or `LazyKeys[]` or `fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[]` | Lazy-load on key mapping |
+| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
+| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
### Lazy Loading
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index bad46ab..4cf01b5 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -346,7 +346,7 @@ function M.find(modname, opts)
local updated = false
---@type LazyCoreConfig
local Config = package.loaded["lazy.core.config"]
- if Config then
+ if Config and Config.spec then
for _, plugin in pairs(Config.spec.plugins) do
if not (M.indexed[plugin.dir] or plugin._.loaded or plugin.module == false) then
updated = M._index(plugin.dir) or updated
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 1ed7361..663a6da 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -231,33 +231,14 @@ function M._load(plugin, reason, opts)
end)
end
--- Merges super opts or runs the opts function to override opts or return new ones
----@param plugin LazyPlugin
-function M.opts(plugin)
- ---@type table
- local opts = plugin._.super and M.opts(plugin._.super) or {}
- ---@type PluginOpts?
- local plugin_opts = rawget(plugin, "opts")
-
- if type(plugin_opts) == "table" then
- opts = Util.merge(opts, plugin_opts)
- elseif type(plugin_opts) == "function" then
- local new_opts = plugin_opts(plugin, opts)
- if new_opts then
- opts = new_opts
- end
- end
-
- return opts
-end
-
--- runs plugin config
---@param plugin LazyPlugin
function M.config(plugin)
+ local opts = Plugin.values(plugin, "opts", false)
local fn
if type(plugin.config) == "function" then
fn = function()
- plugin.config(plugin, M.opts(plugin))
+ plugin.config(plugin, opts)
end
else
local normname = Util.normname(plugin.name)
@@ -274,7 +255,7 @@ function M.config(plugin)
end
if #mods == 1 then
fn = function()
- require(mods[1]).setup(M.opts(plugin))
+ require(mods[1]).setup(opts)
end
else
return Util.error(
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index 88713e4..21634a4 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -7,9 +7,6 @@ local Cache = require("lazy.core.cache")
local M = {}
M.loading = false
-local list_merge = { "dependencies" }
-vim.list_extend(list_merge, vim.tbl_values(Handler.types))
-
---@class LazySpecLoader
---@field plugins table
---@field disabled table
@@ -27,11 +24,26 @@ function Spec.new(spec)
self.modules = {}
self.notifs = {}
if spec then
- self:normalize(spec)
+ self:parse(spec)
end
return self
end
+function Spec:parse(spec)
+ self:normalize(spec)
+
+ -- calculate handlers
+ for _, plugin in pairs(self.plugins) do
+ for _, handler in pairs(Handler.types) do
+ if plugin[handler] then
+ plugin[handler] = M.values(plugin, handler, true)
+ end
+ end
+ end
+
+ self:fix_disabled()
+end
+
-- PERF: optimized code to get package name without using lua patterns
function Spec.get_name(pkg)
local name = pkg:sub(-4) == ".git" and pkg:sub(1, -5) or pkg
@@ -88,11 +100,6 @@ function Spec:add(plugin, results, is_dep)
return
end
- plugin.event = type(plugin.event) == "string" and { plugin.event } or plugin.event
- plugin.keys = type(plugin.keys) == "string" and { plugin.keys } or plugin.keys
- plugin.cmd = type(plugin.cmd) == "string" and { plugin.cmd } or plugin.cmd
- plugin.ft = type(plugin.ft) == "string" and { plugin.ft } or plugin.ft
-
if type(plugin.config) == "table" then
self:warn(
"{" .. plugin.name .. "}: setting a table to `Plugin.config` is deprecated. Please use `Plugin.opts` instead"
@@ -272,14 +279,10 @@ function Spec:merge(old, new)
self:error("Two plugins with the same name and different url:\n" .. vim.inspect({ old = old, new = new }))
end
- for _, prop in ipairs(list_merge) do
- if new[prop] and old[prop] then
- if new[prop].__merge == nil then
- new[prop].__merge = true
- end
- new[prop] = Util.merge(old[prop], new[prop])
- end
+ if new.dependencies and old.dependencies then
+ vim.list_extend(new.dependencies, old.dependencies)
end
+
new._.super = old
setmetatable(new, { __index = old })
@@ -335,10 +338,8 @@ function M.load()
-- load specs
Util.track("spec")
Config.spec = Spec.new()
- Config.spec:normalize(vim.deepcopy(Config.options.spec))
+ Config.spec:parse({ vim.deepcopy(Config.options.spec), "folke/lazy.nvim" })
- -- add ourselves
- Config.spec:add({ "folke/lazy.nvim" })
-- override some lazy props
local lazy = Config.spec.plugins["lazy.nvim"]
if lazy then
@@ -349,7 +350,6 @@ function M.load()
end
lazy._.loaded = {}
end
- Config.spec:fix_disabled()
local existing = Config.plugins
Config.plugins = Config.spec.plugins
@@ -395,4 +395,25 @@ function M.has_errors(plugin)
return false
end
+-- Merges super values or runs the values function to override values or return new ones
+-- Used for opts, cmd, event, ft and keys
+---@param plugin LazyPlugin
+---@param prop string
+---@param is_list? boolean
+function M.values(plugin, prop, is_list)
+ ---@type table
+ local ret = plugin._.super and M.values(plugin._.super, prop) or {}
+ local values = rawget(plugin, prop)
+
+ if not values then
+ return ret
+ elseif type(values) == "function" then
+ ret = values(plugin, ret) or ret
+ return type(ret) == "table" and ret or { ret }
+ end
+
+ values = type(values) == "table" and values or { values }
+ return is_list and vim.list_extend(ret, values) or Util.merge(ret, values)
+end
+
return M
diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua
index 557a2f4..6a0c055 100644
--- a/lua/lazy/types.lua
+++ b/lua/lazy/types.lua
@@ -27,7 +27,7 @@
---@field event? string[]
---@field cmd? string[]
---@field ft? string[]
----@field keys? string[]
+---@field keys? (string|LazyKeys)[]
---@field module? false
---@class LazyPluginRef
@@ -53,10 +53,10 @@
---@field _ LazyPluginState
---@class LazyPluginSpecHandlers
----@field event? string[]|string
----@field cmd? string[]|string
----@field ft? string[]|string
----@field keys? string|string[]|LazyKeys[]
+---@field event? string[]|string|fun(self:LazyPlugin, event:string[]):string[]
+---@field cmd? string[]|string|fun(self:LazyPlugin, cmd:string[]):string[]
+---@field ft? string[]|string|fun(self:LazyPlugin, ft:string[]):string[]
+---@field keys? string|string[]|LazyKeys[]|fun(self:LazyPlugin, keys:string[]):(string|LazyKeys)[]
---@field module? false
---@class LazyPluginSpec: LazyPluginBase,LazyPluginSpecHandlers,LazyPluginHooks,LazyPluginRef
diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua
index ac8b3cb..d948817 100644
--- a/tests/core/plugin_spec.lua
+++ b/tests/core/plugin_spec.lua
@@ -262,7 +262,6 @@ describe("plugin spec opt", function()
}
for test, ret in pairs(tests) do
local spec = Plugin.Spec.new(test)
- spec:fix_disabled()
assert(#spec.notifs == 0)
if ret then
assert(spec.plugins.bar)
From 784bb3c10093b428c4dcc97f113fee8ce501350d Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 12 Jan 2023 13:13:30 +0100
Subject: [PATCH 070/992] refactor: removed special `__merge` functionality
---
lua/lazy/core/util.lua | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index c13d7fe..8a937a8 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -298,27 +298,10 @@ function M.debug(msg, opts)
end
end
-local MERGE = "__merge"
-
local function can_merge(v)
return type(v) == "table" and (vim.tbl_isempty(v) or not M.is_list(v))
end
-local function can_extend(v)
- return type(v) == "table" and (vim.tbl_isempty(v) or M.is_list(v))
-end
-
----@param v any|{__merge:boolean}
----@param merge? boolean
----@return boolean?
-local function check_merge(v, merge)
- if type(v) == "table" and v[MERGE] ~= nil then
- merge = v[MERGE]
- v[MERGE] = nil
- end
- return merge
-end
-
--- Merges the values similar to vim.tbl_deep_extend with the **force** behavior,
--- but the values can be any type, in which case they override the values on the left.
--- Values will me merged in-place in the first left-most table. If you want the result to be in
@@ -335,19 +318,12 @@ function M.merge(...)
ret = nil
end
- local merge = check_merge(ret)
-
for i = 2, #values, 1 do
local value = values[i]
- merge = check_merge(value, merge)
- if can_merge(ret) and can_merge(value) and merge ~= false then
+ if can_merge(ret) and can_merge(value) then
for k, v in pairs(value) do
ret[k] = M.merge(ret[k], v)
end
- elseif can_extend(ret) and can_extend(value) and merge then
- for _, v in ipairs(value) do
- ret[#ret + 1] = v
- end
elseif value == vim.NIL then
ret = nil
else
From 3f3d9df324022f1054d895c7eaeee6fe4e284545 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 12 Jan 2023 13:13:45 +0100
Subject: [PATCH 071/992] test: fixed tests for `Plugin.opts`
---
tests/core/plugin_spec.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua
index d948817..2eaf349 100644
--- a/tests/core/plugin_spec.lua
+++ b/tests/core/plugin_spec.lua
@@ -311,7 +311,7 @@ describe("plugin opts", function()
for _, test in ipairs(tests) do
local spec = Plugin.Spec.new(test.spec)
assert(spec.plugins.foo)
- assert.same(test.opts, Loader.opts(spec.plugins.foo))
+ assert.same(test.opts, Plugin.values(spec.plugins.foo, "opts"))
end
end)
end)
From f3695bc5be49353a996af2fbd6d51e8367a778d0 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 12 Jan 2023 13:16:23 +0100
Subject: [PATCH 072/992] test: fixed tests for `Util.merge`
---
tests/core/util_spec.lua | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/tests/core/util_spec.lua b/tests/core/util_spec.lua
index 7d16ca6..87102d3 100644
--- a/tests/core/util_spec.lua
+++ b/tests/core/util_spec.lua
@@ -148,25 +148,13 @@ describe("util", function()
output = { a = { 3 } },
},
{
- input = { { b = { 1, 2 } }, { a = { 3 }, __merge = false } },
+ input = { { b = { 1, 2 } }, { a = { 3 }, b = vim.NIL } },
output = { a = { 3 } },
},
{
- input = { { a = 1 }, { b = 2, __merge = false } },
+ input = { { a = 1 }, { b = 2, a = vim.NIL } },
output = { b = 2 },
},
- {
- input = { { a = { 1, 2 } }, { a = { 3, __merge = true } } },
- output = { a = { 1, 2, 3 } },
- },
- {
- input = { { a = { 1, 2, __merge = true } }, { a = { 3 } } },
- output = { a = { 1, 2, 3 } },
- },
- {
- input = { { a = { 1, 2, __merge = true } }, { a = { 3, __merge = false } } },
- output = { a = { 3 } },
- },
}
for _, test in ipairs(tests) do
From 70e5e08dc12613006ee86489291929c592f1145d Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 12 Jan 2023 12:17:08 +0000
Subject: [PATCH 073/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 50 +++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 5a9c935..c02a70e 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -111,31 +111,31 @@ It is recommended to run `:checkhealth lazy` after installation
PLUGIN SPEC *lazy.nvim-plugin-spec*
-│ Property │ Type │ Description │
-│[1] │string? │Short plugin url. Will be expanded using config.git.url_format │
-│**dir** │string? │A directory pointing to a local plugin │
-│**url** │string? │A custom git url where the plugin is hosted │
-│**name** │string? │A custom name for the plugin used for the local plugin directory and as the display name │
-│**dev** │boolean? │When true, a local plugin directory will be used instead. See config.dev │
-│**lazy** │boolean? │When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers │
-│**enabled** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be included in the spec │
-│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
-│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
-│**init** │fun(LazyPlugin) │init functions are always executed during startup │
-│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
-│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). See also opts. │
-│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
-│**branch** │string? │Branch of the repository │
-│**tag** │string? │Tag of the repository │
-│**commit** │string? │Commit of the repository │
-│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
-│**pin** │boolean? │When true, this plugin will not be included in updates │
-│**event** │string? or string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
-│**cmd** │string? or string[] │Lazy-load on command │
-│**ft** │string? or string[] │Lazy-load on filetype │
-│**keys** │string? or string[] or LazyKeys[] │Lazy-load on key mapping │
-│**module** │false? │Do not automatically load this Lua module when it’s required somewhere │
-│**priority** │number? │Only useful for **start** plugins (lazy=false) to force loading certain plugins first. Default priority is 50. It’s recommended to set this to a high number for colorschemes. │
+│ Property │ Type │ Description │
+│[1] │string? │Short plugin url. Will be expanded using config.git.url_format │
+│**dir** │string? │A directory pointing to a local plugin │
+│**url** │string? │A custom git url where the plugin is hosted │
+│**name** │string? │A custom name for the plugin used for the local plugin directory and as the display name │
+│**dev** │boolean? │When true, a local plugin directory will be used instead. See config.dev │
+│**lazy** │boolean? │When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers │
+│**enabled** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be included in the spec │
+│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
+│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
+│**init** │fun(LazyPlugin) │init functions are always executed during startup │
+│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
+│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). See also opts. │
+│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
+│**branch** │string? │Branch of the repository │
+│**tag** │string? │Tag of the repository │
+│**commit** │string? │Commit of the repository │
+│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
+│**pin** │boolean? │When true, this plugin will not be included in updates │
+│**event** │string? or string[] or fun(self:LazyPlugin, event:string[]):string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
+│**cmd** │string? or string[] or fun(self:LazyPlugin, cmd:string[]):string[] │Lazy-load on command │
+│**ft** │string? or string[] or fun(self:LazyPlugin, ft:string[]):string[] │Lazy-load on filetype │
+│**keys** │string? or string[] or LazyKeys[] or fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[] │Lazy-load on key mapping │
+│**module** │false? │Do not automatically load this Lua module when it’s required somewhere │
+│**priority** │number? │Only useful for **start** plugins (lazy=false) to force loading certain plugins first. Default priority is 50. It’s recommended to set this to a high number for colorschemes. │
LAZY LOADING ~
From 81017b99e799d08ea5297b0f620e4404ef41e51f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 13 Jan 2023 08:58:18 +0100
Subject: [PATCH 074/992] fix(cache): de-duplicate topmods. Fixes #349
---
lua/lazy/core/cache.lua | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 4cf01b5..3f30ff2 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -246,7 +246,9 @@ function M._index(path)
if not vim.tbl_contains(M.topmods[topname], path) then
table.insert(M.topmods[topname], path)
end
- table.insert(M.indexed[path], topname)
+ if not vim.tbl_contains(M.indexed[path], topname) then
+ table.insert(M.indexed[path], topname)
+ end
end
end)
return true
From b73312aa32c685ff68771a31d209a43866e4d4b2 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 13 Jan 2023 09:00:15 +0100
Subject: [PATCH 075/992] fix: use `vim.api.nvim_exec_autocmds` instead of
`vim.cmd[[do]]` to prevent weird `vim.notify` behavior
---
lua/lazy/core/loader.lua | 2 +-
lua/lazy/core/util.lua | 2 +-
lua/lazy/init.lua | 2 +-
lua/lazy/manage/init.lua | 11 ++++++-----
lua/lazy/manage/reloader.lua | 4 ++--
lua/lazy/manage/task/init.lua | 4 ++--
lua/lazy/stats.lua | 2 +-
lua/lazy/view/float.lua | 2 +-
8 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 663a6da..e5f727a 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -227,7 +227,7 @@ function M._load(plugin, reason, opts)
plugin._.loaded.time = Util.track().time
table.remove(M.loading)
vim.schedule(function()
- vim.cmd("do User LazyRender")
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
end)
end
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 8a937a8..bc7720d 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -143,7 +143,7 @@ function M.very_lazy()
local function _load()
vim.schedule(function()
vim.g.did_very_lazy = true
- vim.cmd("do User VeryLazy")
+ vim.api.nvim_exec_autocmds("User", { pattern = "VeryLazy", modeline = false })
end)
end
diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua
index d3b8b93..a0b073a 100644
--- a/lua/lazy/init.lua
+++ b/lua/lazy/init.lua
@@ -64,7 +64,7 @@ function M.setup(spec, opts)
Loader.startup()
-- all done!
- vim.cmd("do User LazyDone")
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyDone", modeline = false })
require("lazy.stats").track("LazyDone")
end
diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua
index d14a7b8..9ffda73 100644
--- a/lua/lazy/manage/init.lua
+++ b/lua/lazy/manage/init.lua
@@ -42,16 +42,17 @@ function M.run(ropts, opts)
local runner = Runner.new(ropts)
runner:start()
- vim.cmd([[do User LazyRender]])
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
-- wait for post-install to finish
runner:wait(function()
- vim.cmd([[do User LazyRender]])
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
Plugin.update_state()
require("lazy.manage.checker").fast_check({ report = false })
local mode = opts.mode
if mode then
- vim.cmd("do User Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2))
+ local event = "Lazy" .. mode:sub(1, 1):upper() .. mode:sub(2)
+ vim.api.nvim_exec_autocmds("User", { pattern = event, modeline = false })
end
end)
@@ -179,7 +180,7 @@ function M.sync(opts)
clean:wait(function()
install:wait(function()
update:wait(function()
- vim.cmd([[do User LazySync]])
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazySync", modeline = false })
end)
end)
end)
@@ -211,7 +212,7 @@ function M.clear(plugins)
end, plugin._.tasks)
end
end
- vim.cmd([[do User LazyRender]])
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
end
return M
diff --git a/lua/lazy/manage/reloader.lua b/lua/lazy/manage/reloader.lua
index 5f9a74b..7d30d3d 100644
--- a/lua/lazy/manage/reloader.lua
+++ b/lua/lazy/manage/reloader.lua
@@ -83,8 +83,8 @@ function M.check(start)
Util.warn(lines)
end
Plugin.load()
- vim.cmd([[do User LazyRender]])
- vim.cmd([[do User LazyReload]])
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyReload", modeline = false })
end)
end
end
diff --git a/lua/lazy/manage/task/init.lua b/lua/lazy/manage/task/init.lua
index 92596e3..a68c7d7 100644
--- a/lua/lazy/manage/task/init.lua
+++ b/lua/lazy/manage/task/init.lua
@@ -85,7 +85,7 @@ function Task:_check()
if self._opts.on_done then
self._opts.on_done(self)
end
- vim.cmd("do User LazyRender")
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
vim.api.nvim_exec_autocmds("User", {
pattern = "LazyPlugin" .. self.name:sub(1, 1):upper() .. self.name:sub(2),
data = { plugin = self.plugin.name },
@@ -131,7 +131,7 @@ function Task:spawn(cmd, opts)
if on_line then
pcall(on_line, line)
end
- vim.cmd("do User LazyRender")
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyRender", modeline = false })
end
---@param output string
diff --git a/lua/lazy/stats.lua b/lua/lazy/stats.lua
index facc9dc..a2ccdd8 100644
--- a/lua/lazy/stats.lua
+++ b/lua/lazy/stats.lua
@@ -21,7 +21,7 @@ M.C = nil
function M.on_ui_enter()
M._stats.startuptime = M.track("UIEnter")
- vim.cmd([[do User LazyVimStarted]])
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyVimStarted", modeline = false })
end
function M.track(event)
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index d6e3c39..821121b 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -127,7 +127,7 @@ function M:mount()
config.style = self.opts.style ~= "" and self.opts.style or nil
vim.api.nvim_win_set_config(self.win, config)
opts()
- vim.cmd([[do User LazyFloatResized]])
+ vim.api.nvim_exec_autocmds("User", { pattern = "LazyFloatResized", modeline = false })
end,
})
end
From 7b0d1a786664a707accfde09ecf54315e91f9a2b Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 13 Jan 2023 09:00:38 +0100
Subject: [PATCH 076/992] fix(float): only clear diagnostics for valid buffers
---
lua/lazy/view/float.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index 821121b..2a2cc5f 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -173,12 +173,12 @@ function M:close()
local win = self.win
self.win = nil
self.buf = nil
- vim.diagnostic.reset(Config.ns, buf)
vim.schedule(function()
if win and vim.api.nvim_win_is_valid(win) then
vim.api.nvim_win_close(win, true)
end
if buf and vim.api.nvim_buf_is_valid(buf) then
+ vim.diagnostic.reset(Config.ns, buf)
vim.api.nvim_buf_delete(buf, { force = true })
end
end)
From e2556e38c738d62ea7c7956dc4c3b276ac595823 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 13 Jan 2023 08:02:17 +0000
Subject: [PATCH 077/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index c02a70e..cabc587 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 12
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 13
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 7b78ce33327c3caee9a0933792b432bce5c6c885 Mon Sep 17 00:00:00 2001
From: hgigas <100573434+hgigas@users.noreply.github.com>
Date: Fri, 13 Jan 2023 09:05:13 +0100
Subject: [PATCH 078/992] feat(commands): allow commands like `Lazy ... | ...`
(#377)
Set bar attribute:
```
-bar The command can be followed by a "|" and another command.
```
---
lua/lazy/view/commands.lua | 1 +
1 file changed, 1 insertion(+)
diff --git a/lua/lazy/view/commands.lua b/lua/lazy/view/commands.lua
index 4944e65..f1ab877 100644
--- a/lua/lazy/view/commands.lua
+++ b/lua/lazy/view/commands.lua
@@ -94,6 +94,7 @@ function M.setup()
end
M.cmd(prefix, opts)
end, {
+ bar = true,
bang = true,
nargs = "?",
desc = "Lazy",
From 0d0d5870a3265f1c92a89dccef4a592c44e70179 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Fri, 13 Jan 2023 09:13:19 +0100
Subject: [PATCH 079/992] chore(main): release 9.2.0 (#376)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 16 ++++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c80a637..ff567f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,21 @@
# Changelog
+## [9.2.0](https://github.com/folke/lazy.nvim/compare/v9.1.3...v9.2.0) (2023-01-13)
+
+
+### Features
+
+* **commands:** allow commands like `Lazy ... | ...` ([#377](https://github.com/folke/lazy.nvim/issues/377)) ([7b78ce3](https://github.com/folke/lazy.nvim/commit/7b78ce33327c3caee9a0933792b432bce5c6c885))
+* **spec:** event, keys, ft and cmd can now also be a function that returns the values to be used ([2128ca9](https://github.com/folke/lazy.nvim/commit/2128ca90fb67928e5e23590142de9c94fc0a0d31))
+
+
+### Bug Fixes
+
+* **cache:** de-duplicate topmods. Fixes [#349](https://github.com/folke/lazy.nvim/issues/349) ([81017b9](https://github.com/folke/lazy.nvim/commit/81017b99e799d08ea5297b0f620e4404ef41e51f))
+* **float:** only clear diagnostics for valid buffers ([7b0d1a7](https://github.com/folke/lazy.nvim/commit/7b0d1a786664a707accfde09ecf54315e91f9a2b))
+* **ui:** open diff and others over the ui. Don't try to be smart about it. Fixes [#361](https://github.com/folke/lazy.nvim/issues/361) ([3fbe4fe](https://github.com/folke/lazy.nvim/commit/3fbe4fe27ab6b58e5dafd45c5316ec62791907d4))
+* use `vim.api.nvim_exec_autocmds` instead of `vim.cmd[[do]]` to prevent weird `vim.notify` behavior ([b73312a](https://github.com/folke/lazy.nvim/commit/b73312aa32c685ff68771a31d209a43866e4d4b2))
+
## [9.1.3](https://github.com/folke/lazy.nvim/compare/v9.1.2...v9.1.3) (2023-01-11)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 97cc131..5f56dc1 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,7 +139,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.1.3" -- x-release-please-version
+M.version = "9.2.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 666ed7bf73eb5895253c1155bd29270b066cbdac Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 13 Jan 2023 09:19:51 +0100
Subject: [PATCH 080/992] fix(build): make sure `rplugin.vim` is loaded when
doing a build. Fixes #382
---
lua/lazy/manage/task/plugin.lua | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lua/lazy/manage/task/plugin.lua b/lua/lazy/manage/task/plugin.lua
index 9b32b51..9e6d84a 100644
--- a/lua/lazy/manage/task/plugin.lua
+++ b/lua/lazy/manage/task/plugin.lua
@@ -13,6 +13,8 @@ M.build = {
return not (plugin._.dirty and plugin.build)
end,
run = function(self)
+ vim.cmd([[silent! runtime plugin/rplugin.vim]])
+
Loader.load(self.plugin, { task = "build" })
local builders = self.plugin.build
From 891cdfacde26ebef718f67800276dec16dddd25e Mon Sep 17 00:00:00 2001
From: Axel Dahlberg
Date: Sun, 15 Jan 2023 03:01:12 -0800
Subject: [PATCH 081/992] docs: clarify config = true (#390)
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e568d31..6eeaf12 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ require("lazy").setup({
| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
-| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. See also `opts`. |
+| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. See also `opts`. To use the default implementation without `opts` set `config` to `true`. |
| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
| **branch** | `string?` | Branch of the repository |
| **tag** | `string?` | Tag of the repository |
From 6ac67d46dc19aa4c9b72c0e9d716bcae9e122204 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sun, 15 Jan 2023 11:02:12 +0000
Subject: [PATCH 082/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index cabc587..bc7f626 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 13
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 15
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
@@ -123,7 +123,7 @@ PLUGIN SPEC *lazy.nvim-plugin-spec*
│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
│**init** │fun(LazyPlugin) │init functions are always executed during startup │
│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
-│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). See also opts. │
+│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). See also opts. To use the default implementation without opts set config to true. │
│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
│**branch** │string? │Branch of the repository │
│**tag** │string? │Tag of the repository │
From 1b219c17042733dd9bda43ce1478e8ba26d22b1b Mon Sep 17 00:00:00 2001
From: Jay Patel <36803168+jay-babu@users.noreply.github.com>
Date: Sun, 15 Jan 2023 13:56:51 -0500
Subject: [PATCH 083/992] docs: Update plugin table `config` to represent how
`require` works (#399)
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 6eeaf12..79602a5 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ require("lazy").setup({
| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
-| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. See also `opts`. To use the default implementation without `opts` set `config` to `true`. |
+| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. `"plugin"` will default to `name` if specified, otherwise `lazy.nvim` will do its best to guess the correct plugin name. See also `opts`. To use the default implementation without `opts` set `config` to `true`. |
| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
| **branch** | `string?` | Branch of the repository |
| **tag** | `string?` | Tag of the repository |
From 9375f68dcdd616d12d4e95dac1c01e15d62a8b32 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sun, 15 Jan 2023 18:57:33 +0000
Subject: [PATCH 084/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 50 +++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index bc7f626..1e309ae 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -111,31 +111,31 @@ It is recommended to run `:checkhealth lazy` after installation
PLUGIN SPEC *lazy.nvim-plugin-spec*
-│ Property │ Type │ Description │
-│[1] │string? │Short plugin url. Will be expanded using config.git.url_format │
-│**dir** │string? │A directory pointing to a local plugin │
-│**url** │string? │A custom git url where the plugin is hosted │
-│**name** │string? │A custom name for the plugin used for the local plugin directory and as the display name │
-│**dev** │boolean? │When true, a local plugin directory will be used instead. See config.dev │
-│**lazy** │boolean? │When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers │
-│**enabled** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be included in the spec │
-│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
-│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
-│**init** │fun(LazyPlugin) │init functions are always executed during startup │
-│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
-│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). See also opts. To use the default implementation without opts set config to true. │
-│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
-│**branch** │string? │Branch of the repository │
-│**tag** │string? │Tag of the repository │
-│**commit** │string? │Commit of the repository │
-│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
-│**pin** │boolean? │When true, this plugin will not be included in updates │
-│**event** │string? or string[] or fun(self:LazyPlugin, event:string[]):string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
-│**cmd** │string? or string[] or fun(self:LazyPlugin, cmd:string[]):string[] │Lazy-load on command │
-│**ft** │string? or string[] or fun(self:LazyPlugin, ft:string[]):string[] │Lazy-load on filetype │
-│**keys** │string? or string[] or LazyKeys[] or fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[] │Lazy-load on key mapping │
-│**module** │false? │Do not automatically load this Lua module when it’s required somewhere │
-│**priority** │number? │Only useful for **start** plugins (lazy=false) to force loading certain plugins first. Default priority is 50. It’s recommended to set this to a high number for colorschemes. │
+│ Property │ Type │ Description │
+│[1] │string? │Short plugin url. Will be expanded using config.git.url_format │
+│**dir** │string? │A directory pointing to a local plugin │
+│**url** │string? │A custom git url where the plugin is hosted │
+│**name** │string? │A custom name for the plugin used for the local plugin directory and as the display name │
+│**dev** │boolean? │When true, a local plugin directory will be used instead. See config.dev │
+│**lazy** │boolean? │When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers │
+│**enabled** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be included in the spec │
+│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
+│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
+│**init** │fun(LazyPlugin) │init functions are always executed during startup │
+│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
+│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). "plugin" will default to name if specified, otherwise lazy.nvim will do its best to guess the correct plugin name. See also opts. To use the default implementation without opts set config to true. │
+│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
+│**branch** │string? │Branch of the repository │
+│**tag** │string? │Tag of the repository │
+│**commit** │string? │Commit of the repository │
+│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
+│**pin** │boolean? │When true, this plugin will not be included in updates │
+│**event** │string? or string[] or fun(self:LazyPlugin, event:string[]):string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
+│**cmd** │string? or string[] or fun(self:LazyPlugin, cmd:string[]):string[] │Lazy-load on command │
+│**ft** │string? or string[] or fun(self:LazyPlugin, ft:string[]):string[] │Lazy-load on filetype │
+│**keys** │string? or string[] or LazyKeys[] or fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[] │Lazy-load on key mapping │
+│**module** │false? │Do not automatically load this Lua module when it’s required somewhere │
+│**priority** │number? │Only useful for **start** plugins (lazy=false) to force loading certain plugins first. Default priority is 50. It’s recommended to set this to a high number for colorschemes. │
LAZY LOADING ~
From 7160ca419e7be36536dd8fe90ad0bf26cdd773ae Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 15 Jan 2023 20:00:07 +0100
Subject: [PATCH 085/992] fix(loader): load plugin opts inside a `try` clause
to report errors
---
lua/lazy/core/loader.lua | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index e5f727a..68f05e8 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -234,10 +234,10 @@ end
--- runs plugin config
---@param plugin LazyPlugin
function M.config(plugin)
- local opts = Plugin.values(plugin, "opts", false)
local fn
if type(plugin.config) == "function" then
fn = function()
+ local opts = Plugin.values(plugin, "opts", false)
plugin.config(plugin, opts)
end
else
@@ -255,6 +255,7 @@ function M.config(plugin)
end
if #mods == 1 then
fn = function()
+ local opts = Plugin.values(plugin, "opts", false)
require(mods[1]).setup(opts)
end
else
From 984008f7ae17c1a8009d9e2f6dc007e13b90a744 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 15 Jan 2023 20:04:37 +0100
Subject: [PATCH 086/992] refactor: add lazy.nvim with full url. Fixes #396
---
lua/lazy/core/plugin.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index 21634a4..d44f525 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -338,7 +338,7 @@ function M.load()
-- load specs
Util.track("spec")
Config.spec = Spec.new()
- Config.spec:parse({ vim.deepcopy(Config.options.spec), "folke/lazy.nvim" })
+ Config.spec:parse({ vim.deepcopy(Config.options.spec), { url = "https://github.com/folke/lazy.nvim.git" } })
-- override some lazy props
local lazy = Config.spec.plugins["lazy.nvim"]
From fdf0332fe17d9c01f92a8464c04213123a025a07 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 16 Jan 2023 10:16:35 +0100
Subject: [PATCH 087/992] feat(keys): allow overriding a keys value to
`vim.NIL` to not add the key
---
lua/lazy/core/handler/init.lua | 37 ++++++++------------
lua/lazy/core/handler/keys.lua | 64 +++++++++++++++++++---------------
2 files changed, 51 insertions(+), 50 deletions(-)
diff --git a/lua/lazy/core/handler/init.lua b/lua/lazy/core/handler/init.lua
index 67ad44c..5e9074b 100644
--- a/lua/lazy/core/handler/init.lua
+++ b/lua/lazy/core/handler/init.lua
@@ -62,28 +62,28 @@ function M.new(type)
return self
end
----@param value string
+---@param _value string
---@protected
-function M:_add(value) end
+function M:_add(_value) end
----@param value string
+---@param _value string
---@protected
-function M:_del(value) end
+function M:_del(_value) end
----@return string
-function M:key(value)
- return value
+---@param plugin LazyPlugin
+function M:values(plugin)
+ ---@type table
+ local values = {}
+ ---@diagnostic disable-next-line: no-unknown
+ for _, value in ipairs(plugin[self.type] or {}) do
+ values[value] = value
+ end
+ return values
end
---@param plugin LazyPlugin
function M:add(plugin)
- local values = {}
- for _, value in ipairs(plugin[self.type] or {}) do
- local key = self:key(value)
- values[key] = value
- end
-
- for key, value in pairs(values) do
+ for key, value in pairs(self:values(plugin)) do
if not self.active[key] then
self.active[key] = {}
self:_add(value)
@@ -94,14 +94,7 @@ end
---@param plugin LazyPlugin
function M:del(plugin)
- local values = {}
- for _, value in ipairs(plugin[self.type] or {}) do
- local key = self:key(value)
- values[key] = value
- end
-
- for key, value in pairs(values) do
- local key = self:key(value)
+ for key, value in pairs(self:values(plugin)) do
if self.active[key] and self.active[key][plugin.name] then
self.active[key][plugin.name] = nil
if vim.tbl_isempty(self.active[key]) then
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index dd55cef..ddd97ef 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -9,6 +9,7 @@ local Loader = require("lazy.core.loader")
---@field noremap? boolean
---@field remap? boolean
---@field expr? boolean
+---@field id string
---@class LazyKeysHandler:LazyHandler
local M = {}
@@ -54,48 +55,56 @@ function M.parse(value)
local ret = vim.deepcopy(value)
ret = type(ret) == "string" and { ret } or ret --[[@as LazyKeys]]
ret.mode = ret.mode or "n"
+ ret.id = (ret[1] or "")
+ if ret.mode then
+ local mode = ret.mode
+ if type(mode) == "table" then
+ ---@cast mode string[]
+ table.sort(mode)
+ ret.id = ret.id .. " (" .. table.concat(mode, ", ") .. ")"
+ elseif mode ~= "n" then
+ ret.id = ret.id .. " (" .. mode .. ")"
+ end
+ end
return ret
end
+---@param plugin LazyPlugin
+function M:values(plugin)
+ ---@type table
+ local values = {}
+ ---@diagnostic disable-next-line: no-unknown
+ for _, value in ipairs(plugin[self.type] or {}) do
+ local keys = M.parse(value)
+ if keys[2] == vim.NIL then
+ values[keys.id] = nil
+ else
+ values[keys.id] = keys
+ end
+ end
+ return values
+end
+
function M.opts(keys)
local opts = {}
for k, v in pairs(keys) do
- if type(k) ~= "number" and k ~= "mode" then
+ if type(k) ~= "number" and k ~= "mode" and k ~= "id" then
opts[k] = v
end
end
return opts
end
----@return string
-function M:key(value)
- if type(value) == "string" then
- return value
- end
- local mode = value.mode or { "n" }
- if type(mode) == "string" then
- mode = { mode }
- end
- ---@type string
- local ret = value[1]
- if #mode > 0 then
- ret = table.concat(mode, ",") .. ": " .. ret
- end
- return ret
-end
-
----@param value string|LazyKeys
-function M:_add(value)
- local keys = M.parse(value)
+---@param keys LazyKeys
+function M:_add(keys)
local lhs = keys[1]
local opts = M.opts(keys)
vim.keymap.set(keys.mode, lhs, function()
- local key = self:key(value)
- local plugins = self.active[key]
+ local plugins = self.active[keys.id]
-- always delete the mapping immediately to prevent recursive mappings
- self:_del(value)
- self.active[key] = nil
+ self:_del(keys)
+ self.active[keys.id] = nil
Util.track({ keys = lhs })
Loader.load(plugins, { keys = lhs })
@@ -104,9 +113,8 @@ function M:_add(value)
end, opts)
end
----@param value string|LazyKeys
-function M:_del(value)
- local keys = M.parse(value)
+---@param keys LazyKeys
+function M:_del(keys)
pcall(vim.keymap.del, keys.mode, keys[1])
if keys[2] then
vim.keymap.set(keys.mode, keys[1], keys[2], M.opts(keys))
From 02482b1ec94e6c2801dbbfc40122c936dd157dea Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 16 Jan 2023 09:17:20 +0000
Subject: [PATCH 088/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 1e309ae..323a4e6 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 15
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 16
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 1e67dc0d56b8e7cf6befdc7176a4a54e17afc244 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 16 Jan 2023 12:29:19 +0100
Subject: [PATCH 089/992] perf(util): dont trigger VeryLazy autocmds when
exiting
---
lua/lazy/core/util.lua | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index bc7720d..58874d3 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -142,6 +142,9 @@ end
function M.very_lazy()
local function _load()
vim.schedule(function()
+ if vim.v.exiting then
+ return
+ end
vim.g.did_very_lazy = true
vim.api.nvim_exec_autocmds("User", { pattern = "VeryLazy", modeline = false })
end)
From e8cb863703276c579d781b7e4e0b27052df8fc68 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 16 Jan 2023 12:33:03 +0100
Subject: [PATCH 090/992] fix(util): rever
---
lua/lazy/core/util.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 58874d3..5173520 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -142,9 +142,9 @@ end
function M.very_lazy()
local function _load()
vim.schedule(function()
- if vim.v.exiting then
- return
- end
+ -- if vim.v.exiting then
+ -- return
+ -- end
vim.g.did_very_lazy = true
vim.api.nvim_exec_autocmds("User", { pattern = "VeryLazy", modeline = false })
end)
From efe72d98e6fb71252bd9a904c00a40ccd54ebf05 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 16 Jan 2023 12:37:28 +0100
Subject: [PATCH 091/992] perf(util): properly check that Neovim is exiting.
Dont run VeryLazy when that's the case
---
lua/lazy/core/util.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 5173520..3a27a8f 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -142,9 +142,9 @@ end
function M.very_lazy()
local function _load()
vim.schedule(function()
- -- if vim.v.exiting then
- -- return
- -- end
+ if vim.v.exiting ~= vim.NIL then
+ return
+ end
vim.g.did_very_lazy = true
vim.api.nvim_exec_autocmds("User", { pattern = "VeryLazy", modeline = false })
end)
From 0cbd91d2cd942cc448b4648dbc7ba57515a2867c Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 16 Jan 2023 17:03:43 +0100
Subject: [PATCH 092/992] feat(spec): you can now override specs using only the
plugin name instead of the short url
---
lua/lazy/core/plugin.lua | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index d44f525..bbc68ad 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -64,7 +64,9 @@ function Spec:add(plugin, results, is_dep)
return plugin
end
- if not plugin.url and plugin[1] then
+ local is_ref = plugin[1] and not plugin[1]:find("/", 1, true)
+
+ if not plugin.url and not is_ref and plugin[1] then
local prefix = plugin[1]:sub(1, 4)
if prefix == "http" or prefix == "git@" then
plugin.url = plugin[1]
@@ -95,6 +97,8 @@ function Spec:add(plugin, results, is_dep)
-- remote plugin
plugin.dir = Config.options.root .. "/" .. plugin.name
end
+ elseif is_ref then
+ plugin.name = plugin[1]
else
self:error("Invalid plugin spec " .. vim.inspect(plugin))
return
From 208f91b52fff5f7b6120b19b80e529821d70d009 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 16 Jan 2023 20:41:29 +0100
Subject: [PATCH 093/992] feat(git): some debugging tools for git
---
lua/lazy/manage/git.lua | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lua/lazy/manage/git.lua b/lua/lazy/manage/git.lua
index 76f7009..5d431ae 100644
--- a/lua/lazy/manage/git.lua
+++ b/lua/lazy/manage/git.lua
@@ -225,4 +225,14 @@ function M.get_config(repo)
return ret
end
+function M.count(repo, commit1, commit2)
+ local lines = Process.exec({ "git", "rev-list", "--count", commit1 .. ".." .. commit2 }, { cwd = repo })
+ return tonumber(lines[1] or "0") or 0
+end
+
+function M.age(repo, commit)
+ local lines = Process.exec({ "git", "show", "-s", "--format=%cr", "--date=short", commit }, { cwd = repo })
+ return lines[1] or ""
+end
+
return M
From 870af80c68f3834ffcbced1528cce6197ec2b4ae Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 16 Jan 2023 21:27:55 +0100
Subject: [PATCH 094/992] feat(spec): overriding keys with an rhs of `false`
will remove the key instead
---
lua/lazy/core/handler/keys.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index ddd97ef..dd78581 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -76,7 +76,7 @@ function M:values(plugin)
---@diagnostic disable-next-line: no-unknown
for _, value in ipairs(plugin[self.type] or {}) do
local keys = M.parse(value)
- if keys[2] == vim.NIL then
+ if keys[2] == vim.NIL or keys[2] == false then
values[keys.id] = nil
else
values[keys.id] = keys
From c05d61d208afaccb2a6765c0a6eb2d4e506a8c18 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Mon, 16 Jan 2023 22:18:55 +0100
Subject: [PATCH 095/992] chore(main): release 9.3.0 (#385)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 23 +++++++++++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff567f7..b01a57e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,28 @@
# Changelog
+## [9.3.0](https://github.com/folke/lazy.nvim/compare/v9.2.0...v9.3.0) (2023-01-16)
+
+
+### Features
+
+* **git:** some debugging tools for git ([208f91b](https://github.com/folke/lazy.nvim/commit/208f91b52fff5f7b6120b19b80e529821d70d009))
+* **keys:** allow overriding a keys value to `vim.NIL` to not add the key ([fdf0332](https://github.com/folke/lazy.nvim/commit/fdf0332fe17d9c01f92a8464c04213123a025a07))
+* **spec:** overriding keys with an rhs of `false` will remove the key instead ([870af80](https://github.com/folke/lazy.nvim/commit/870af80c68f3834ffcbced1528cce6197ec2b4ae))
+* **spec:** you can now override specs using only the plugin name instead of the short url ([0cbd91d](https://github.com/folke/lazy.nvim/commit/0cbd91d2cd942cc448b4648dbc7ba57515a2867c))
+
+
+### Bug Fixes
+
+* **build:** make sure `rplugin.vim` is loaded when doing a build. Fixes [#382](https://github.com/folke/lazy.nvim/issues/382) ([666ed7b](https://github.com/folke/lazy.nvim/commit/666ed7bf73eb5895253c1155bd29270b066cbdac))
+* **loader:** load plugin opts inside a `try` clause to report errors ([7160ca4](https://github.com/folke/lazy.nvim/commit/7160ca419e7be36536dd8fe90ad0bf26cdd773ae))
+* **util:** rever ([e8cb863](https://github.com/folke/lazy.nvim/commit/e8cb863703276c579d781b7e4e0b27052df8fc68))
+
+
+### Performance Improvements
+
+* **util:** dont trigger VeryLazy autocmds when exiting ([1e67dc0](https://github.com/folke/lazy.nvim/commit/1e67dc0d56b8e7cf6befdc7176a4a54e17afc244))
+* **util:** properly check that Neovim is exiting. Dont run VeryLazy when that's the case ([efe72d9](https://github.com/folke/lazy.nvim/commit/efe72d98e6fb71252bd9a904c00a40ccd54ebf05))
+
## [9.2.0](https://github.com/folke/lazy.nvim/compare/v9.1.3...v9.2.0) (2023-01-13)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 5f56dc1..270dede 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,7 +139,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.2.0" -- x-release-please-version
+M.version = "9.3.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From bd37afc96e4d64a41744298f24772dddb5286fd5 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 17 Jan 2023 13:14:25 +0100
Subject: [PATCH 096/992] fix(git): when a `Plugin.branch` is set, don't use
`config.defaults.version`. Fixes #409
---
lua/lazy/manage/git.lua | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/manage/git.lua b/lua/lazy/manage/git.lua
index 5d431ae..116c5fe 100644
--- a/lua/lazy/manage/git.lua
+++ b/lua/lazy/manage/git.lua
@@ -131,7 +131,8 @@ function M.get_target(plugin)
commit = M.ref(plugin.dir, "tags/" .. plugin.tag),
}
end
- local version = plugin.version == nil and Config.options.defaults.version or plugin.version
+
+ local version = (plugin.version == nil and plugin.branch == nil) and Config.options.defaults.version or plugin.version
if version then
local last = Semver.last(M.get_versions(plugin.dir, version))
if last then
From f95d97a91ceb0faf6dcd5756099c4707727a741a Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Tue, 17 Jan 2023 12:15:13 +0000
Subject: [PATCH 097/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 323a4e6..1668cce 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 16
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 17
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From baaf8ddfff6cf0c2b8729c2b76b2b140cb40d382 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 17 Jan 2023 13:54:34 +0100
Subject: [PATCH 098/992] fix(spec): when overriding a spec by name that has
not been imported yet, show an error when needed
---
lua/lazy/core/plugin.lua | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index bbc68ad..3bb6ee5 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -57,7 +57,7 @@ end
function Spec:add(plugin, results, is_dep)
-- check if we already processed this spec. Can happen when a user uses the same instance of a spec in multiple specs
-- see https://github.com/folke/lazy.nvim/issues/45
- if plugin._ then
+ if rawget(plugin, "_") then
if results then
table.insert(results, plugin.name)
end
@@ -119,6 +119,9 @@ function Spec:add(plugin, results, is_dep)
plugin.dependencies = plugin.dependencies and self:normalize(plugin.dependencies, {}, true) or nil
if self.plugins[plugin.name] then
plugin = self:merge(self.plugins[plugin.name], plugin)
+ elseif is_ref then
+ self:error("Plugin spec for **" .. plugin.name .. "** not found.\n```lua\n" .. vim.inspect(plugin) .. "\n```")
+ return
end
self.plugins[plugin.name] = plugin
if results then
From da4e8cc2450ec428d370032b5b3790b01889c4a4 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 17 Jan 2023 13:55:04 +0100
Subject: [PATCH 099/992] fix(spec): dont copy dep and super state from
existing plugins
---
lua/lazy/core/plugin.lua | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index 3bb6ee5..baf63ef 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -363,7 +363,11 @@ function M.load()
-- copy state. This wont do anything during startup
for name, plugin in pairs(existing) do
if Config.plugins[name] then
+ local dep = Config.plugins[name]._.dep
+ local super = Config.plugins[name]._.super
Config.plugins[name]._ = plugin._
+ Config.plugins[name]._.dep = dep
+ Config.plugins[name]._.super = super
end
end
Util.track()
From 1b2a6f631c9b2ef98005acec8369c7298fe7a751 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 17 Jan 2023 14:00:33 +0100
Subject: [PATCH 100/992] perf(plugin): de-duplicate dependencies, keys, ft,
event and cmd
---
lua/lazy/core/plugin.lua | 4 ++--
lua/lazy/core/util.lua | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index baf63ef..b7179c9 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -287,7 +287,7 @@ function Spec:merge(old, new)
end
if new.dependencies and old.dependencies then
- vim.list_extend(new.dependencies, old.dependencies)
+ Util.extend(new.dependencies, old.dependencies)
end
new._.super = old
@@ -424,7 +424,7 @@ function M.values(plugin, prop, is_list)
end
values = type(values) == "table" and values or { values }
- return is_list and vim.list_extend(ret, values) or Util.merge(ret, values)
+ return is_list and Util.extend(ret, values) or Util.merge(ret, values)
end
return M
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 3a27a8f..9a81d28 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -222,6 +222,23 @@ function M.lsmod(modname, fn)
end)
end
+---@generic T
+---@param list T[]
+---@param add T[]
+---@return T[]
+function M.extend(list, add)
+ local idx = {}
+ for _, v in ipairs(list) do
+ idx[v] = v
+ end
+ for _, a in ipairs(add) do
+ if not idx[a] then
+ table.insert(list, a)
+ end
+ end
+ return list
+end
+
---@alias LazyNotifyOpts {lang?:string, title?:string, level?:number}
---@param msg string|string[]
From c791c0ed7d7bbcdc06a58b79eb4625682c60964c Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 17 Jan 2023 14:35:21 +0100
Subject: [PATCH 101/992] fix: work-around for libuv issue where
fs_scandir_next sometimes fails to return a file type
---
lua/lazy/core/util.lua | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 9a81d28..7411664 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -175,13 +175,16 @@ function M.ls(path, fn)
local handle = vim.loop.fs_scandir(path)
while handle do
local name, t = vim.loop.fs_scandir_next(handle)
- -- HACK: assume type is a file if no type returned
- -- see https://github.com/folke/lazy.nvim/issues/306
- t = t or "file"
if not name then
break
end
- if fn(path .. "/" .. name, name, t) == false then
+
+ local fname = path .. "/" .. name
+
+ -- HACK: type is not always returned due to a bug in luv,
+ -- so fecth it with fs_stat instead when needed.
+ -- see https://github.com/folke/lazy.nvim/issues/306
+ if fn(fname, name, t or vim.loop.fs_stat(fname).type) == false then
break
end
end
From 4f60facf18b34ae06d164485aa2ce879e21e44fc Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 17 Jan 2023 14:37:11 +0100
Subject: [PATCH 102/992] chore(main): release 9.3.1 (#410)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 15 +++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b01a57e..2093139 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,20 @@
# Changelog
+## [9.3.1](https://github.com/folke/lazy.nvim/compare/v9.3.0...v9.3.1) (2023-01-17)
+
+
+### Bug Fixes
+
+* **git:** when a `Plugin.branch` is set, don't use `config.defaults.version`. Fixes [#409](https://github.com/folke/lazy.nvim/issues/409) ([bd37afc](https://github.com/folke/lazy.nvim/commit/bd37afc96e4d64a41744298f24772dddb5286fd5))
+* **spec:** dont copy dep and super state from existing plugins ([da4e8cc](https://github.com/folke/lazy.nvim/commit/da4e8cc2450ec428d370032b5b3790b01889c4a4))
+* **spec:** when overriding a spec by name that has not been imported yet, show an error when needed ([baaf8dd](https://github.com/folke/lazy.nvim/commit/baaf8ddfff6cf0c2b8729c2b76b2b140cb40d382))
+* work-around for libuv issue where fs_scandir_next sometimes fails to return a file type ([c791c0e](https://github.com/folke/lazy.nvim/commit/c791c0ed7d7bbcdc06a58b79eb4625682c60964c))
+
+
+### Performance Improvements
+
+* **plugin:** de-duplicate dependencies, keys, ft, event and cmd ([1b2a6f6](https://github.com/folke/lazy.nvim/commit/1b2a6f631c9b2ef98005acec8369c7298fe7a751))
+
## [9.3.0](https://github.com/folke/lazy.nvim/compare/v9.2.0...v9.3.0) (2023-01-16)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 270dede..c1290c1 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -139,7 +139,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.3.0" -- x-release-please-version
+M.version = "9.3.1" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 27ca918bc3d02ea20b3fd901c8919e9925555444 Mon Sep 17 00:00:00 2001
From: Hans Chen
Date: Tue, 17 Jan 2023 22:03:23 +0100
Subject: [PATCH 103/992] fix(render): get profile_{sort,filter} key bindings
from ViewConfig (#416)
---
lua/lazy/view/render.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index 1c0bd3c..d0cf458 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -583,12 +583,12 @@ function M:profile()
self:append("Profile", "LazyH2"):nl():nl()
self
:append("You can press ")
- :append("", "LazySpecial")
+ :append(ViewConfig.keys.profile_sort, "LazySpecial")
:append(" to change sorting between chronological order & time taken.")
:nl()
self
:append("Press ")
- :append("", "LazySpecial")
+ :append(ViewConfig.keys.profile_filter, "LazySpecial")
:append(" to filter profiling entries that took more time than a given threshold")
:nl()
From c3a0d444f6a6995ccb16a386feafc949fabc4b50 Mon Sep 17 00:00:00 2001
From: "Daniel M. Capella"
Date: Wed, 18 Jan 2023 07:34:29 +0000
Subject: [PATCH 104/992] docs: fix indentation (#419)
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 79602a5..b5c7b9a 100644
--- a/README.md
+++ b/README.md
@@ -650,8 +650,8 @@ require("lazy").setup("plugins")
```lua
return {
"folke/neodev.nvim",
- "folke/which-key.nvim",
- { "folke/neoconf.nvim", cmd = "Neoconf" },
+ "folke/which-key.nvim",
+ { "folke/neoconf.nvim", cmd = "Neoconf" },
}
```
From 835731f102fd495380c3b5d7def5ea6ebc3ed3df Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 18 Jan 2023 07:35:12 +0000
Subject: [PATCH 105/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 1668cce..b9b7c0b 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 17
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 18
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
@@ -708,8 +708,8 @@ Example:
>lua
return {
"folke/neodev.nvim",
- "folke/which-key.nvim",
- { "folke/neoconf.nvim", cmd = "Neoconf" },
+ "folke/which-key.nvim",
+ { "folke/neoconf.nvim", cmd = "Neoconf" },
}
<
From 813fc944d797fe1b43abe12866a9ef7af403c35c Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 18 Jan 2023 08:24:43 +0100
Subject: [PATCH 106/992] feat(checker): checker will now save last check time
and only check at configured frequency even after restarting Neovim
---
lua/lazy/core/config.lua | 1 +
lua/lazy/manage/checker.lua | 16 ++++++++++---
lua/lazy/state.lua | 45 +++++++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+), 3 deletions(-)
create mode 100644 lua/lazy/state.lua
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index c1290c1..c2d4cda 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -136,6 +136,7 @@ M.defaults = {
-- only generate markdown helptags for plugins that dont have docs
skip_if_doc_exists = true,
},
+ state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
debug = false,
}
diff --git a/lua/lazy/manage/checker.lua b/lua/lazy/manage/checker.lua
index 477c63d..7622812 100644
--- a/lua/lazy/manage/checker.lua
+++ b/lua/lazy/manage/checker.lua
@@ -3,6 +3,7 @@ local Manage = require("lazy.manage")
local Util = require("lazy.util")
local Plugin = require("lazy.core.plugin")
local Git = require("lazy.manage.git")
+local State = require("lazy.state")
local M = {}
@@ -12,7 +13,14 @@ M.reported = {}
function M.start()
M.fast_check()
- M.check()
+ M.schedule()
+end
+
+function M.schedule()
+ State.read() -- update state
+ local next_check = State.checker.last_check + Config.options.checker.frequency - os.time()
+ next_check = math.max(next_check, 0)
+ vim.defer_fn(M.check, next_check * 1000)
end
---@param opts? {report:boolean} report defaults to true
@@ -32,6 +40,8 @@ function M.fast_check(opts)
end
function M.check()
+ State.checker.last_check = os.time()
+ State.write() -- update state
local errors = false
for _, plugin in pairs(Config.plugins) do
if Plugin.has_errors(plugin) then
@@ -40,14 +50,14 @@ function M.check()
end
end
if errors then
- vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
+ M.schedule()
else
Manage.check({
show = false,
concurrency = Config.options.checker.concurrency,
}):wait(function()
M.report()
- vim.defer_fn(M.check, Config.options.checker.frequency * 1000)
+ M.schedule()
end)
end
end
diff --git a/lua/lazy/state.lua b/lua/lazy/state.lua
new file mode 100644
index 0000000..80e4c2e
--- /dev/null
+++ b/lua/lazy/state.lua
@@ -0,0 +1,45 @@
+local Util = require("lazy.util")
+local Config = require("lazy.core.config")
+
+---@type LazyState
+local M = {}
+
+---@class LazyState
+local defaults = {
+ checker = {
+ last_check = 0,
+ },
+}
+
+---@type LazyState
+local data = nil
+
+function M.read()
+ pcall(function()
+ ---@diagnostic disable-next-line: cast-local-type
+ data = vim.json.decode(Util.read_file(Config.options.state))
+ end)
+ data = vim.tbl_deep_extend("force", {}, defaults, data or {})
+end
+
+function M.write()
+ vim.fn.mkdir(vim.fn.fnamemodify(Config.options.state, ":p:h"), "p")
+ Util.write_file(Config.options.state, vim.json.encode(data))
+end
+
+function M.__index(_, key)
+ if not data then
+ M.read()
+ end
+ return data[key]
+end
+
+function M.__setindex(_, key, value)
+ if not data then
+ M.read()
+ end
+ ---@diagnostic disable-next-line: no-unknown
+ data[key] = value
+end
+
+return setmetatable(M, M)
From c389ad552bd5c2050783ac6cd6e54f5fbba3c7bc Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 18 Jan 2023 08:31:55 +0100
Subject: [PATCH 107/992] fix(spec): dont complain about an invalid short url,
when a full url is set. Fixes #421
---
lua/lazy/core/plugin.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index b7179c9..4873249 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -119,7 +119,7 @@ function Spec:add(plugin, results, is_dep)
plugin.dependencies = plugin.dependencies and self:normalize(plugin.dependencies, {}, true) or nil
if self.plugins[plugin.name] then
plugin = self:merge(self.plugins[plugin.name], plugin)
- elseif is_ref then
+ elseif is_ref and not plugin.url then
self:error("Plugin spec for **" .. plugin.name .. "** not found.\n```lua\n" .. vim.inspect(plugin) .. "\n```")
return
end
From d6fc848067d603800b9e63a7b22b7e5853c6bd7a Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 19 Jan 2023 08:45:27 +0100
Subject: [PATCH 108/992] feat: added `config.ui.wrap` and improved wrapping
when wrap=true. Fixes #422
---
lua/lazy/core/config.lua | 1 +
lua/lazy/view/init.lua | 9 +++++++++
lua/lazy/view/render.lua | 6 +++---
lua/lazy/view/text.lua | 10 ++++++++--
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index c2d4cda..0140c53 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -37,6 +37,7 @@ M.defaults = {
ui = {
-- a number <1 is a percentage., >1 is a fixed size
size = { width = 0.8, height = 0.8 },
+ wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
icons = {
diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua
index ac64e74..efdb75e 100644
--- a/lua/lazy/view/init.lua
+++ b/lua/lazy/view/init.lua
@@ -52,6 +52,15 @@ function M.create()
---@cast self LazyView
Float.init(self)
+ if Config.options.ui.wrap then
+ vim.wo[self.win].wrap = true
+ vim.wo[self.win].linebreak = true
+ vim.wo[self.win].breakindent = true
+ -- vim.wo[self.win].breakindentopt = "shift:8"
+ else
+ vim.wo[self.win].wrap = false
+ end
+
require("lazy.view.colors").setup()
self.state = vim.deepcopy(default_state)
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index d0cf458..e4f4529 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -127,13 +127,13 @@ function M:title()
if self.view.state.mode == mode.name then
if mode.name == "home" then
- self:append(title, "LazyH1")
+ self:append(title, "LazyH1", { wrap = true })
else
- self:append(title, "LazyButtonActive")
+ self:append(title, "LazyButtonActive", { wrap = true })
self:highlight({ ["%(.%)"] = "LazySpecial" })
end
else
- self:append(title, "LazyButton")
+ self:append(title, "LazyButton", { wrap = true })
self:highlight({ ["%(.%)"] = "LazySpecial" })
end
self:append(" ")
diff --git a/lua/lazy/view/text.lua b/lua/lazy/view/text.lua
index 00c081a..5351db4 100644
--- a/lua/lazy/view/text.lua
+++ b/lua/lazy/view/text.lua
@@ -21,7 +21,7 @@ end
---@param str string
---@param hl? string|Extmark
----@param opts? {indent?: number, prefix?: string}
+---@param opts? {indent?: number, prefix?: string, wrap?: boolean}
function Text:append(str, hl, opts)
opts = opts or {}
if #self._lines == 0 then
@@ -39,7 +39,13 @@ function Text:append(str, hl, opts)
if l > 1 then
self:nl()
end
- if str ~= "" and self:col() > 0 and self:col() + vim.fn.strwidth(line) + self.padding > self.wrap then
+ if
+ Config.options.ui.wrap
+ and opts.wrap
+ and str ~= ""
+ and self:col() > 0
+ and self:col() + vim.fn.strwidth(line) + self.padding > self.wrap
+ then
self:nl()
end
table.insert(self._lines[#self._lines], {
From 4739c2d95af17acb786ed33445f59b7b13671417 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 19 Jan 2023 07:46:21 +0000
Subject: [PATCH 109/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index b9b7c0b..caee52f 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 18
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 19
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 3f8cc2c0dfa46849c472f4e22247991f2c26db7b Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Thu, 19 Jan 2023 22:08:58 +0100
Subject: [PATCH 110/992] docs: generated docs
---
README.md | 54 ++++++++++++++++++++++++-----------------------
lua/lazy/docs.lua | 14 ++++++++----
2 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/README.md b/README.md
index b5c7b9a..b5a197d 100644
--- a/README.md
+++ b/README.md
@@ -79,32 +79,32 @@ require("lazy").setup({
## 🔌 Plugin Spec
-| Property | Type | Description |
-| ---------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `[1]` | `string?` | Short plugin url. Will be expanded using `config.git.url_format` |
-| **dir** | `string?` | A directory pointing to a local plugin |
-| **url** | `string?` | A custom git url where the plugin is hosted |
-| **name** | `string?` | A custom name for the plugin used for the local plugin directory and as the display name |
-| **dev** | `boolean?` | When `true`, a local plugin directory will be used instead. See `config.dev` |
-| **lazy** | `boolean?` | When `true`, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are `required`, or when one of the lazy-loading handlers triggers |
-| **enabled** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be included in the spec |
-| **cond** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. |
-| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
-| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
-| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
-| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. `"plugin"` will default to `name` if specified, otherwise `lazy.nvim` will do its best to guess the correct plugin name. See also `opts`. To use the default implementation without `opts` set `config` to `true`. |
-| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
-| **branch** | `string?` | Branch of the repository |
-| **tag** | `string?` | Tag of the repository |
-| **commit** | `string?` | Commit of the repository |
-| **version** | `string?` | Version to use from the repository. Full [Semver](https://devhints.io/semver) ranges are supported |
-| **pin** | `boolean?` | When `true`, this plugin will not be included in updates |
-| **event** | `string?` or `string[]` or `fun(self:LazyPlugin, event:string[]):string[]` | Lazy-load on event. Events can be specified as `BufEnter` or with a pattern like `BufEnter *.lua` |
-| **cmd** | `string?` or `string[]` or `fun(self:LazyPlugin, cmd:string[]):string[]` | Lazy-load on command |
-| **ft** | `string?` or `string[]` or `fun(self:LazyPlugin, ft:string[]):string[]` | Lazy-load on filetype |
-| **keys** | `string?` or `string[]` or `LazyKeys[]` or `fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[]` | Lazy-load on key mapping |
-| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
-| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
+| Property | Type | Description |
+| ---------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `[1]` | `string?` | Short plugin url. Will be expanded using `config.git.url_format` |
+| **dir** | `string?` | A directory pointing to a local plugin |
+| **url** | `string?` | A custom git url where the plugin is hosted |
+| **name** | `string?` | A custom name for the plugin used for the local plugin directory and as the display name |
+| **dev** | `boolean?` | When `true`, a local plugin directory will be used instead. See `config.dev` |
+| **lazy** | `boolean?` | When `true`, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are `required`, or when one of the lazy-loading handlers triggers |
+| **enabled** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be included in the spec |
+| **cond** | `boolean?` or `fun():boolean` | When `false`, or if the `function` returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. |
+| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
+| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
+| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
+| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require("plugin").setup(opts)`. `"plugin"` will default to `name` if specified, otherwise `lazy.nvim` will do its best to guess the correct plugin name. See also `opts`. To use the default implementation without `opts` set `config` to `true`. |
+| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands |
+| **branch** | `string?` | Branch of the repository |
+| **tag** | `string?` | Tag of the repository |
+| **commit** | `string?` | Commit of the repository |
+| **version** | `string?` | Version to use from the repository. Full [Semver](https://devhints.io/semver) ranges are supported |
+| **pin** | `boolean?` | When `true`, this plugin will not be included in updates |
+| **event** | `string?` or `string[]` or `fun(self:LazyPlugin, event:string[]):string[]` | Lazy-load on event. Events can be specified as `BufEnter` or with a pattern like `BufEnter *.lua` |
+| **cmd** | `string?` or `string[]` or `fun(self:LazyPlugin, cmd:string[]):string[]` | Lazy-load on command |
+| **ft** | `string?` or `string[]` or `fun(self:LazyPlugin, ft:string[]):string[]` | Lazy-load on filetype |
+| **keys** | `string?` or `string[]` or `LazyKeys[]` or `fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[]` | Lazy-load on key mapping |
+| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
+| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
### Lazy Loading
@@ -330,6 +330,7 @@ return {
ui = {
-- a number <1 is a percentage., >1 is a fixed size
size = { width = 0.8, height = 0.8 },
+ wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
icons = {
@@ -438,6 +439,7 @@ return {
-- only generate markdown helptags for plugins that dont have docs
skip_if_doc_exists = true,
},
+ state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
}
```
diff --git a/lua/lazy/docs.lua b/lua/lazy/docs.lua
index 44bddfa..da3a166 100644
--- a/lua/lazy/docs.lua
+++ b/lua/lazy/docs.lua
@@ -14,21 +14,27 @@ end
function M.fix_indent(str)
local lines = vim.split(str, "\n")
+ local first = table.remove(lines, 1)
+
local width = 120
for _, line in ipairs(lines) do
- width = math.min(width, #line:match("^%s*"))
+ if not line:find("^%s*$") then
+ width = math.min(width, #line:match("^%s*"))
+ end
end
for l, line in ipairs(lines) do
lines[l] = line:sub(width + 1)
end
+ table.insert(lines, 1, first)
return table.concat(lines, "\n")
end
---@alias ReadmeBlock {content:string, lang?:string}
---@param contents table
-function M.save(contents)
- local readme = Util.read_file("README.md")
+---@param readme_file? string
+function M.save(contents, readme_file)
+ local readme = Util.read_file(readme_file or "README.md")
for tag, block in pairs(contents) do
if type(block) == "string" then
block = { content = block, lang = "lua" }
@@ -48,7 +54,7 @@ function M.save(contents)
end
end
- Util.write_file("README.md", readme)
+ Util.write_file(readme_file or "README.md", readme)
vim.cmd.checktime()
end
From 75dcd5741d76e09b1a41c771fbc8b010a109b5cb Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 19 Jan 2023 21:09:52 +0000
Subject: [PATCH 111/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index caee52f..4e6f21d 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -374,6 +374,7 @@ CONFIGURATION *lazy.nvim-configuration*
ui = {
-- a number <1 is a percentage., >1 is a fixed size
size = { width = 0.8, height = 0.8 },
+ wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
icons = {
@@ -482,6 +483,7 @@ CONFIGURATION *lazy.nvim-configuration*
-- only generate markdown helptags for plugins that dont have docs
skip_if_doc_exists = true,
},
+ state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
}
<
From 9858001c3cdb5713e8d1aeb0f47c23038084fd7c Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 20 Jan 2023 20:41:29 +0100
Subject: [PATCH 112/992] fix(git): unset GIT_DIR when spawning a process.
Fixes #434
---
lua/lazy/manage/process.lua | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/manage/process.lua b/lua/lazy/manage/process.lua
index 79279a0..2ddcff1 100644
--- a/lua/lazy/manage/process.lua
+++ b/lua/lazy/manage/process.lua
@@ -68,7 +68,9 @@ function M.spawn(cmd, opts)
for key, value in
pairs(uv.os_environ() --[[@as string[] ]])
do
- table.insert(env, key .. "=" .. value)
+ if key ~= "GIT_DIR" then
+ table.insert(env, key .. "=" .. value)
+ end
end
local stdout = uv.new_pipe()
From 96d759d1cbd8b0bd0ea0a0c2987f99410272f348 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 20 Jan 2023 19:42:27 +0000
Subject: [PATCH 113/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 4e6f21d..c09b21e 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 19
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 20
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 4008b57d882065814ce27a0f32609d5ea437a6e9 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 22 Jan 2023 14:30:12 +0100
Subject: [PATCH 114/992] fix(checker): make sure we show logs when only doing
a fast check
---
lua/lazy/manage/checker.lua | 9 ++++++++-
lua/lazy/manage/init.lua | 4 ++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/lua/lazy/manage/checker.lua b/lua/lazy/manage/checker.lua
index 7622812..5798b4f 100644
--- a/lua/lazy/manage/checker.lua
+++ b/lua/lazy/manage/checker.lua
@@ -13,7 +13,13 @@ M.reported = {}
function M.start()
M.fast_check()
- M.schedule()
+ if M.schedule() > 0 then
+ Manage.log({
+ show = false,
+ check = true,
+ concurrency = Config.options.checker.concurrency,
+ })
+ end
end
function M.schedule()
@@ -21,6 +27,7 @@ function M.schedule()
local next_check = State.checker.last_check + Config.options.checker.frequency - os.time()
next_check = math.max(next_check, 0)
vim.defer_fn(M.check, next_check * 1000)
+ return next_check
end
---@param opts? {report:boolean} report defaults to true
diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua
index 9ffda73..c4a4da0 100644
--- a/lua/lazy/manage/init.lua
+++ b/lua/lazy/manage/init.lua
@@ -136,13 +136,13 @@ function M.check(opts)
}, opts)
end
----@param opts? ManagerOpts
+---@param opts? ManagerOpts | {check?:boolean}
function M.log(opts)
opts = M.opts(opts, { mode = "log" })
return M.run({
pipeline = {
{ "git.origin", check = true },
- "git.log",
+ { "git.log", check = opts.check },
},
plugins = function(plugin)
return plugin.url and plugin._.installed
From fc3104c44b9a140381daf4bdf8d0454988317a93 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sun, 22 Jan 2023 13:31:18 +0000
Subject: [PATCH 115/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index c09b21e..06c47a8 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 20
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 22
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 7674ee6254279cd5df7db92b41d3a2ca027bde55 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Sun, 22 Jan 2023 15:18:43 +0100
Subject: [PATCH 116/992] chore(main): release 9.4.0 (#417)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 16 ++++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2093139..a84145b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,21 @@
# Changelog
+## [9.4.0](https://github.com/folke/lazy.nvim/compare/v9.3.1...v9.4.0) (2023-01-22)
+
+
+### Features
+
+* added `config.ui.wrap` and improved wrapping when wrap=true. Fixes [#422](https://github.com/folke/lazy.nvim/issues/422) ([d6fc848](https://github.com/folke/lazy.nvim/commit/d6fc848067d603800b9e63a7b22b7e5853c6bd7a))
+* **checker:** checker will now save last check time and only check at configured frequency even after restarting Neovim ([813fc94](https://github.com/folke/lazy.nvim/commit/813fc944d797fe1b43abe12866a9ef7af403c35c))
+
+
+### Bug Fixes
+
+* **checker:** make sure we show logs when only doing a fast check ([4008b57](https://github.com/folke/lazy.nvim/commit/4008b57d882065814ce27a0f32609d5ea437a6e9))
+* **git:** unset GIT_DIR when spawning a process. Fixes [#434](https://github.com/folke/lazy.nvim/issues/434) ([9858001](https://github.com/folke/lazy.nvim/commit/9858001c3cdb5713e8d1aeb0f47c23038084fd7c))
+* **render:** get profile_{sort,filter} key bindings from ViewConfig ([#416](https://github.com/folke/lazy.nvim/issues/416)) ([27ca918](https://github.com/folke/lazy.nvim/commit/27ca918bc3d02ea20b3fd901c8919e9925555444))
+* **spec:** dont complain about an invalid short url, when a full url is set. Fixes [#421](https://github.com/folke/lazy.nvim/issues/421) ([c389ad5](https://github.com/folke/lazy.nvim/commit/c389ad552bd5c2050783ac6cd6e54f5fbba3c7bc))
+
## [9.3.1](https://github.com/folke/lazy.nvim/compare/v9.3.0...v9.3.1) (2023-01-17)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 0140c53..035714e 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -141,7 +141,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.3.1" -- x-release-please-version
+M.version = "9.4.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 21871f2269b7121da2aa5683d9de06ab00a05ba2 Mon Sep 17 00:00:00 2001
From: Sizhe Zhao
Date: Sun, 22 Jan 2023 22:23:26 +0800
Subject: [PATCH 117/992] docs: Fix typo in README.md (#433)
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index b5a197d..a3a2972 100644
--- a/README.md
+++ b/README.md
@@ -416,7 +416,7 @@ return {
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
- paths = {}, -- add any custom paths here that you want to indluce in the rtp
+ paths = {}, -- add any custom paths here that you want to include in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
@@ -622,7 +622,7 @@ In practice this means that step 10 of [Neovim Initialization](https://neovim.io
1. all the plugins' `init()` functions are executed
2. all plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)
3. all files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)
-4. all `/after/plugin` files are sourced (this inludes `/after` from plugins)
+4. all `/after/plugin` files are sourced (this includes `/after` from plugins)
Files from runtime directories are always sourced in alphabetical order.
From 908d71872b4b783e8d80eb13ad5b07212a9731df Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 22 Jan 2023 15:24:13 +0100
Subject: [PATCH 118/992] docs: typo
---
lua/lazy/core/config.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 035714e..ec30ee0 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -114,7 +114,7 @@ M.defaults = {
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
- paths = {}, -- add any custom paths here that you want to indluce in the rtp
+ paths = {}, -- add any custom paths here that you want to includes in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
From cab4682d22a0451bc36a648694235621b5dd808e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sun, 22 Jan 2023 14:25:05 +0000
Subject: [PATCH 119/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 06c47a8..86345f5 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -460,7 +460,7 @@ CONFIGURATION *lazy.nvim-configuration*
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
- paths = {}, -- add any custom paths here that you want to indluce in the rtp
+ paths = {}, -- add any custom paths here that you want to include in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
@@ -671,7 +671,7 @@ In practice this means that step 10 of |Neovim Initialization| is done by Lazy:
1. all the plugins’ `init()` functions are executed
2. all plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)
3. all files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)
-4. all `/after/plugin` files are sourced (this inludes `/after` from plugins)
+4. all `/after/plugin` files are sourced (this includes `/after` from plugins)
Files from runtime directories are always sourced in alphabetical order.
From ed210702f5dc8c24ec6531c0f2484881d9ebe6b6 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 23 Jan 2023 19:17:11 +0100
Subject: [PATCH 120/992] fix(checker): dont clear tasks when running update
check
---
lua/lazy/manage/checker.lua | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lua/lazy/manage/checker.lua b/lua/lazy/manage/checker.lua
index 5798b4f..d45d513 100644
--- a/lua/lazy/manage/checker.lua
+++ b/lua/lazy/manage/checker.lua
@@ -15,6 +15,7 @@ function M.start()
M.fast_check()
if M.schedule() > 0 then
Manage.log({
+ clear = false,
show = false,
check = true,
concurrency = Config.options.checker.concurrency,
@@ -60,6 +61,7 @@ function M.check()
M.schedule()
else
Manage.check({
+ clear = false,
show = false,
concurrency = Config.options.checker.concurrency,
}):wait(function()
From c32a6185ace7cb04572db1637a3010b729a7601e Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 23 Jan 2023 19:17:30 +0100
Subject: [PATCH 121/992] fix(checker): dont check for updates when there's
tasks with errors
---
lua/lazy/manage/checker.lua | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lua/lazy/manage/checker.lua b/lua/lazy/manage/checker.lua
index d45d513..1cc5322 100644
--- a/lua/lazy/manage/checker.lua
+++ b/lua/lazy/manage/checker.lua
@@ -13,7 +13,7 @@ M.reported = {}
function M.start()
M.fast_check()
- if M.schedule() > 0 then
+ if M.schedule() > 0 and not M.has_errors() then
Manage.log({
clear = false,
show = false,
@@ -47,17 +47,19 @@ function M.fast_check(opts)
M.report(opts.report ~= false)
end
+function M.has_errors()
+ for _, plugin in pairs(Config.plugins) do
+ if Plugin.has_errors(plugin) then
+ return true
+ end
+ end
+ return false
+end
+
function M.check()
State.checker.last_check = os.time()
State.write() -- update state
- local errors = false
- for _, plugin in pairs(Config.plugins) do
- if Plugin.has_errors(plugin) then
- errors = true
- break
- end
- end
- if errors then
+ if M.has_errors() then
M.schedule()
else
Manage.check({
From 26a67e3c48951ca3ce47d208c3216143749b0768 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 23 Jan 2023 19:18:15 +0100
Subject: [PATCH 122/992] feat(config): added option to disable git filter. NOT
recommended. Fixes #442
---
lua/lazy/core/config.lua | 4 ++++
lua/lazy/manage/task/git.lua | 10 ++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index ec30ee0..dd1bdae 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -21,6 +21,10 @@ M.defaults = {
log = { "--since=3 days ago" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git",
+ -- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
+ -- then set the below to false. This is should work, but is NOT supported and will
+ -- increase downloads a lot.
+ filter = true,
},
dev = {
-- directory where you store your local plugin projects
diff --git a/lua/lazy/manage/task/git.lua b/lua/lazy/manage/task/git.lua
index c314c90..f07fce0 100644
--- a/lua/lazy/manage/task/git.lua
+++ b/lua/lazy/manage/task/git.lua
@@ -64,10 +64,16 @@ M.clone = {
local args = {
"clone",
self.plugin.url,
- "--filter=blob:none",
+ }
+
+ if Config.options.git.filter then
+ args[#args + 1] = "--filter=blob:none"
+ end
+
+ vim.list_extend(args, {
"--recurse-submodules",
"--progress",
- }
+ })
if self.plugin.branch then
vim.list_extend(args, { "-b", self.plugin.branch })
From 5d9d35404f39de5d7c9365cbc2aa39858929cbfc Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 23 Jan 2023 19:18:48 +0100
Subject: [PATCH 123/992] feat(util): utility method to walk over all modules
in a directory
---
lua/lazy/core/util.lua | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index 7411664..fd2cce4 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -201,6 +201,22 @@ function M.walk(path, fn)
end)
end
+---@param root string
+---@param fn fun(modname:string, modpath:string)
+---@param modname? string
+function M.walkmods(root, fn, modname)
+ modname = modname and (modname:gsub("%.$", "") .. ".") or ""
+ M.ls(root, function(path, name, type)
+ if name == "init.lua" then
+ fn(modname:gsub("%.$", ""), path)
+ elseif (type == "file" or type == "link") and name:sub(-4) == ".lua" then
+ fn(modname .. name:sub(1, -5), path)
+ elseif type == "directory" then
+ M.walkmods(path, fn, modname .. name .. ".")
+ end
+ end)
+end
+
---@param modname string
---@param fn fun(modname:string, modpath:string)
function M.lsmod(modname, fn)
From 9e0b8c399f54d9853abea85ed737e6476917e96c Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 23 Jan 2023 18:19:49 +0000
Subject: [PATCH 124/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 86345f5..403c7f8 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 22
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 23
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 809d67fcf0f6dd5dabdd1c2b88d451cef4695880 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 23 Jan 2023 20:49:44 +0100
Subject: [PATCH 125/992] ci: update actions/checkout to v3
---
.github/workflows/ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8046e5a..94b6d15 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -57,7 +57,7 @@ jobs:
package-name: lazy.nvim
extra-files: |
lua/lazy/core/config.lua
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
run: |
From 772d8888cc6f8e4371c31001197431b24311af48 Mon Sep 17 00:00:00 2001
From: Null Chilly <56817415+nullchilly@users.noreply.github.com>
Date: Wed, 25 Jan 2023 04:55:34 +0700
Subject: [PATCH 126/992] feat(dev): optionally fallback to git when local
plugin doesn't exist (#446)
* feat: fallback to git when local plugin isn't found
* feat(option): fallback to git when local plugin doesn't exist
---
README.md | 1 +
lua/lazy/core/config.lua | 1 +
lua/lazy/core/plugin.lua | 5 ++++-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a3a2972..20f0134 100644
--- a/README.md
+++ b/README.md
@@ -320,6 +320,7 @@ return {
path = "~/projects",
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"}
+ fallback = false, -- Fallback to git when local plugin doesn't exist
},
install = {
-- install missing plugins on startup. This doesn't increase startup time.
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index dd1bdae..e0b50f0 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -31,6 +31,7 @@ M.defaults = {
path = "~/projects",
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"}
+ fallback = false, -- Fallback to git when local plugin doesn't exist
},
install = {
-- install missing plugins on startup. This doesn't increase startup time.
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index 4873249..b79cc6b 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -91,7 +91,10 @@ function Spec:add(plugin, results, is_dep)
end
end
-- dev plugins
- if plugin.dev then
+ if
+ plugin.dev
+ and (not Config.options.dev.fallback or vim.fn.isdirectory(Config.options.dev.path .. "/" .. plugin.name) == 1)
+ then
plugin.dir = Config.options.dev.path .. "/" .. plugin.name
else
-- remote plugin
From 39c4770d8137e9cb304e68b779396c7d0a3c8ec2 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Tue, 24 Jan 2023 21:56:22 +0000
Subject: [PATCH 127/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 403c7f8..86a2198 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 23
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 24
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
@@ -364,6 +364,7 @@ CONFIGURATION *lazy.nvim-configuration*
path = "~/projects",
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"}
+ fallback = false, -- Fallback to git when local plugin doesn't exist
},
install = {
-- install missing plugins on startup. This doesn't increase startup time.
From 9b5cc1bf53f344c8ad829f33c3ac77f5e3ea8da1 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 24 Jan 2023 08:48:14 +0100
Subject: [PATCH 128/992] feat(health): check for git in health checks
---
lua/lazy/health.lua | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua
index 59fa139..31fbd50 100644
--- a/lua/lazy/health.lua
+++ b/lua/lazy/health.lua
@@ -5,6 +5,12 @@ local M = {}
function M.check()
vim.health.report_start("lazy.nvim")
+ if vim.fn.executable("git") == 1 then
+ vim.health.report_ok("Git installed")
+ else
+ vim.health.report_error("Git not installd?")
+ end
+
local sites = vim.opt.packpath:get()
local default_site = vim.fn.stdpath("data") .. "/site"
if not vim.tbl_contains(sites, default_site) then
From 31dd419aaa0bfbab1c827465aa153efbe6b95e1f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 24 Jan 2023 23:01:11 +0100
Subject: [PATCH 129/992] docs: updated
---
README.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 20f0134..40ffda8 100644
--- a/README.md
+++ b/README.md
@@ -314,6 +314,10 @@ return {
log = { "--since=3 days ago" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git",
+ -- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
+ -- then set the below to false. This is should work, but is NOT supported and will
+ -- increase downloads a lot.
+ filter = true,
},
dev = {
-- directory where you store your local plugin projects
@@ -417,7 +421,7 @@ return {
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
- paths = {}, -- add any custom paths here that you want to include in the rtp
+ paths = {}, -- add any custom paths here that you want to includes in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
From a24331762cc41df636d9d3541aafa301f958cf4a Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Tue, 24 Jan 2023 22:01:59 +0000
Subject: [PATCH 130/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 86a2198..357cc29 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -358,6 +358,10 @@ CONFIGURATION *lazy.nvim-configuration*
log = { "--since=3 days ago" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git",
+ -- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
+ -- then set the below to false. This is should work, but is NOT supported and will
+ -- increase downloads a lot.
+ filter = true,
},
dev = {
-- directory where you store your local plugin projects
@@ -461,7 +465,7 @@ CONFIGURATION *lazy.nvim-configuration*
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
- paths = {}, -- add any custom paths here that you want to include in the rtp
+ paths = {}, -- add any custom paths here that you want to includes in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
From 9b208696e139a404d159963b975a5b90af38439b Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 25 Jan 2023 09:10:46 +0100
Subject: [PATCH 131/992] chore(main): release 9.5.0 (#444)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 16 ++++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a84145b..c7949e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,21 @@
# Changelog
+## [9.5.0](https://github.com/folke/lazy.nvim/compare/v9.4.0...v9.5.0) (2023-01-24)
+
+
+### Features
+
+* **config:** added option to disable git filter. NOT recommended. Fixes [#442](https://github.com/folke/lazy.nvim/issues/442) ([26a67e3](https://github.com/folke/lazy.nvim/commit/26a67e3c48951ca3ce47d208c3216143749b0768))
+* **dev:** optionally fallback to git when local plugin doesn't exist ([#446](https://github.com/folke/lazy.nvim/issues/446)) ([772d888](https://github.com/folke/lazy.nvim/commit/772d8888cc6f8e4371c31001197431b24311af48))
+* **health:** check for git in health checks ([9b5cc1b](https://github.com/folke/lazy.nvim/commit/9b5cc1bf53f344c8ad829f33c3ac77f5e3ea8da1))
+* **util:** utility method to walk over all modules in a directory ([5d9d354](https://github.com/folke/lazy.nvim/commit/5d9d35404f39de5d7c9365cbc2aa39858929cbfc))
+
+
+### Bug Fixes
+
+* **checker:** dont check for updates when there's tasks with errors ([c32a618](https://github.com/folke/lazy.nvim/commit/c32a6185ace7cb04572db1637a3010b729a7601e))
+* **checker:** dont clear tasks when running update check ([ed21070](https://github.com/folke/lazy.nvim/commit/ed210702f5dc8c24ec6531c0f2484881d9ebe6b6))
+
## [9.4.0](https://github.com/folke/lazy.nvim/compare/v9.3.1...v9.4.0) (2023-01-22)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index e0b50f0..79bef28 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -146,7 +146,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.4.0" -- x-release-please-version
+M.version = "9.5.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From b64ebb71d4e573a34b0b83801eee60cc6d86a06e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 25 Jan 2023 08:27:21 +0000
Subject: [PATCH 132/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 357cc29..f4674d6 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 24
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 25
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 07fda7bb9808b4848aaabd9400357c56cfbda6d7 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 25 Jan 2023 22:33:45 +0100
Subject: [PATCH 133/992] docs: use another bug emoji. #452
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 40ffda8..c272438 100644
--- a/README.md
+++ b/README.md
@@ -610,7 +610,7 @@ The profiling view shows you why and how long it took to load your plugins.

-## 🪲 Debug
+## 🐛 Debug
See an overview of active lazy-loading handlers and what's in the module cache
From 15fe46a728b7473d4cae368838bbc1c79c3a3f48 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 25 Jan 2023 21:34:44 +0000
Subject: [PATCH 134/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index f4674d6..05b1beb 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -12,7 +12,7 @@ Table of Contents *lazy.nvim-table-of-contents*
- Usage |lazy.nvim-usage|
- Lockfile `lazy-lock.json` |lazy.nvim-lockfile-`lazy-lock.json`|
- Performance |lazy.nvim-performance|
- - 🪲 Debug |lazy.nvim-🪲-debug|
+ - Debug |lazy.nvim-debug|
- Startup Sequence |lazy.nvim-startup-sequence|
- Structuring Your Plugins |lazy.nvim-structuring-your-plugins|
- Migration Guide |lazy.nvim-migration-guide|
@@ -654,7 +654,7 @@ load your plugins.
image
-🪲 DEBUG *lazy.nvim-🪲-debug*
+DEBUG *lazy.nvim-debug*
See an overview of active lazy-loading handlers and what’s in the module
cache
From 0c980312fd6bce744db499acfa5af47871287151 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 1 Feb 2023 08:06:48 +0100
Subject: [PATCH 135/992] fix(commands): sync with plugins list should not
delete those plugins. Fixes #475
---
lua/lazy/manage/init.lua | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua
index c4a4da0..34fc065 100644
--- a/lua/lazy/manage/init.lua
+++ b/lua/lazy/manage/init.lua
@@ -174,7 +174,10 @@ function M.sync(opts)
end)
opts.show = false
end
- local clean = M.clean(opts)
+
+ local clean_opts = vim.deepcopy(opts)
+ clean_opts.plugins = nil
+ local clean = M.clean(clean_opts)
local install = M.install(opts)
local update = M.update(opts)
clean:wait(function()
From c83563d34acd20cbd5180e40442f2e0f095fb3ff Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 1 Feb 2023 07:08:28 +0000
Subject: [PATCH 136/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 05b1beb..c4b8119 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 January 25
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 01
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 527f83cae50b99d16327447eb813b4f73e09ec0d Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 1 Feb 2023 08:08:44 +0100
Subject: [PATCH 137/992] fix(health): existing packages on windows. Fixes #474
---
lua/lazy/health.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua
index 31fbd50..75a85a6 100644
--- a/lua/lazy/health.lua
+++ b/lua/lazy/health.lua
@@ -20,7 +20,7 @@ function M.check()
local existing = false
for _, site in pairs(sites) do
for _, packs in ipairs(vim.fn.expand(site .. "/pack/*", false, true)) do
- if not packs:find("/dist$") and vim.loop.fs_stat(packs) then
+ if not packs:find("[/\\]dist$") and vim.loop.fs_stat(packs) then
existing = true
vim.health.report_warn("found existing packages at `" .. packs .. "`")
end
From 3d2dcb2d5ef99106c5ff412da88c6f59a9f8a693 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 1 Feb 2023 08:26:20 +0100
Subject: [PATCH 138/992] fix(log): properly check if plugin dir is a git repo
before running git log
---
lua/lazy/manage/task/git.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/manage/task/git.lua b/lua/lazy/manage/task/git.lua
index f07fce0..377b3ef 100644
--- a/lua/lazy/manage/task/git.lua
+++ b/lua/lazy/manage/task/git.lua
@@ -15,7 +15,7 @@ M.log = {
return true
end
local stat = vim.loop.fs_stat(plugin.dir .. "/.git")
- return stat and stat.type ~= "directory"
+ return not (stat and stat.type == "directory")
end,
---@param opts {args?: string[], updated?:boolean, check?:boolean}
run = function(self, opts)
From 452d4eb719c5067f0bae497dc870554cd300758f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 6 Feb 2023 09:16:49 +0100
Subject: [PATCH 139/992] fix(process): allow overriding GIT_SSH_COMMAND. Fixes
#491. Fixes #492
---
lua/lazy/manage/process.lua | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/lua/lazy/manage/process.lua b/lua/lazy/manage/process.lua
index 2ddcff1..fd5f898 100644
--- a/lua/lazy/manage/process.lua
+++ b/lua/lazy/manage/process.lua
@@ -49,7 +49,7 @@ local uv = vim.loop
---@field on_line? fun(string)
---@field on_exit? fun(ok:boolean, output:string)
---@field timeout? number
----@field env? string[]
+---@field env? table
---@param opts? ProcessOpts
---@param cmd string
@@ -57,20 +57,15 @@ function M.spawn(cmd, opts)
opts = opts or {}
opts.timeout = opts.timeout or (Config.options.git and Config.options.git.timeout * 1000)
- local env = {
- "GIT_TERMINAL_PROMPT=0",
- "GIT_SSH_COMMAND=ssh -oBatchMode=yes",
- }
- if opts.env then
- vim.list_extend(env, opts.env)
- end
+ local env = vim.tbl_extend("force", {
+ GIT_SSH_COMMAND = "ssh -oBatchMode=yes",
+ }, uv.os_environ(), opts.env or {})
+ env.GIT_DIR = nil
+ env.GIT_TERMINAL_PROMPT = "0"
- for key, value in
- pairs(uv.os_environ() --[[@as string[] ]])
- do
- if key ~= "GIT_DIR" then
- table.insert(env, key .. "=" .. value)
- end
+ local env_flat = {}
+ for k, v in pairs(env) do
+ env_flat[#env_flat + 1] = k .. "=" .. v
end
local stdout = uv.new_pipe()
@@ -95,7 +90,7 @@ function M.spawn(cmd, opts)
stdio = { nil, stdout, stderr },
args = opts.args,
cwd = opts.cwd,
- env = env,
+ env = env_flat,
}, function(exit_code, signal)
M.running[handle] = nil
if timeout then
From 2e8f6e6e8f1543ee9762525bd150c1b1e319555b Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 6 Feb 2023 08:17:59 +0000
Subject: [PATCH 140/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index c4b8119..dd94667 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 01
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 06
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 812ffcf21c314e2fddc3ac84aca6b22627a49a36 Mon Sep 17 00:00:00 2001
From: Maurice Mertens
Date: Mon, 6 Feb 2023 09:24:24 +0100
Subject: [PATCH 141/992] docs: clarifies install step (#495)
Co-authored-by: Maurice Mertens
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c272438..b2fa8a3 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,7 @@ vim.opt.rtp:prepend(lazypath)
-Next step is to add **lazy.nvim** to the top of your `init.lua`
+Next step is to add **lazy.nvim** below the code added in the last step in `init.lua`
```lua
require("lazy").setup(plugins, opts)
From 326556008a1574389be7fa9d670abada10ce1323 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 6 Feb 2023 08:25:32 +0000
Subject: [PATCH 142/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index dd94667..b3a3fcd 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -81,7 +81,8 @@ You can add the following Lua code to your `init.lua` to bootstrap
<
-Next step is to add **lazy.nvim** to the top of your `init.lua`
+Next step is to add **lazy.nvim** below the code added in the last step in
+`init.lua`
>lua
require("lazy").setup(plugins, opts)
From 0e4017152d90cff89232713a5baca24e8411dbaa Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 7 Feb 2023 17:09:39 +0100
Subject: [PATCH 143/992] chore(main): release 9.5.1 (#478)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 10 ++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c7949e7..1f1b1a2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# Changelog
+## [9.5.1](https://github.com/folke/lazy.nvim/compare/v9.5.0...v9.5.1) (2023-02-06)
+
+
+### Bug Fixes
+
+* **commands:** sync with plugins list should not delete those plugins. Fixes [#475](https://github.com/folke/lazy.nvim/issues/475) ([0c98031](https://github.com/folke/lazy.nvim/commit/0c980312fd6bce744db499acfa5af47871287151))
+* **health:** existing packages on windows. Fixes [#474](https://github.com/folke/lazy.nvim/issues/474) ([527f83c](https://github.com/folke/lazy.nvim/commit/527f83cae50b99d16327447eb813b4f73e09ec0d))
+* **log:** properly check if plugin dir is a git repo before running git log ([3d2dcb2](https://github.com/folke/lazy.nvim/commit/3d2dcb2d5ef99106c5ff412da88c6f59a9f8a693))
+* **process:** allow overriding GIT_SSH_COMMAND. Fixes [#491](https://github.com/folke/lazy.nvim/issues/491). Fixes [#492](https://github.com/folke/lazy.nvim/issues/492) ([452d4eb](https://github.com/folke/lazy.nvim/commit/452d4eb719c5067f0bae497dc870554cd300758f))
+
## [9.5.0](https://github.com/folke/lazy.nvim/compare/v9.4.0...v9.5.0) (2023-01-24)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 79bef28..8b0a124 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -146,7 +146,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.5.0" -- x-release-please-version
+M.version = "9.5.1" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 0dcc9071dfc98a3b9ea2585019073fb90a84a616 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Tue, 7 Feb 2023 16:10:30 +0000
Subject: [PATCH 144/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index b3a3fcd..849e3b4 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 06
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 07
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 3c29f196f4b0f083f2b94c3337599a189f4eef84 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 7 Feb 2023 20:56:54 +0100
Subject: [PATCH 145/992] feat(cmd): use cmd table instead of trying to create
the cmd string. Fixes #472
---
lua/lazy/core/handler/cmd.lua | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/lua/lazy/core/handler/cmd.lua b/lua/lazy/core/handler/cmd.lua
index a4913e0..142eda8 100644
--- a/lua/lazy/core/handler/cmd.lua
+++ b/lua/lazy/core/handler/cmd.lua
@@ -14,16 +14,22 @@ end
---@param cmd string
function M:_add(cmd)
vim.api.nvim_create_user_command(cmd, function(event)
+ local command = {
+ cmd = cmd,
+ bang = event.bang or nil,
+ mods = event.smods,
+ args = event.fargs,
+ count = event.count >= 0 and event.count or nil,
+ }
+
+ if event.range == 1 then
+ command.range = { event.line1 }
+ elseif event.range == 2 then
+ command.range = { event.line1, event.line2 }
+ end
+
self:_load(cmd)
- vim.cmd(
- ("%s %s%s%s %s"):format(
- event.mods or "",
- event.line1 == event.line2 and "" or event.line1 .. "," .. event.line2,
- cmd,
- event.bang and "!" or "",
- event.args or ""
- )
- )
+ vim.cmd(command)
end, {
bang = true,
range = true,
From 48c9b37294f31e3875435bca41d0c923fdd6eea4 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 7 Feb 2023 22:02:20 +0100
Subject: [PATCH 146/992] chore(main): release 9.6.0 (#504)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 7 +++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f1b1a2..8e66b59 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## [9.6.0](https://github.com/folke/lazy.nvim/compare/v9.5.1...v9.6.0) (2023-02-07)
+
+
+### Features
+
+* **cmd:** use cmd table instead of trying to create the cmd string. Fixes [#472](https://github.com/folke/lazy.nvim/issues/472) ([3c29f19](https://github.com/folke/lazy.nvim/commit/3c29f196f4b0f083f2b94c3337599a189f4eef84))
+
## [9.5.1](https://github.com/folke/lazy.nvim/compare/v9.5.0...v9.5.1) (2023-02-06)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 8b0a124..62ff3d7 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -146,7 +146,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.5.1" -- x-release-please-version
+M.version = "9.6.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 49b43def14f7e130cc27c7041ca2942142a881ed Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 7 Feb 2023 22:59:05 +0100
Subject: [PATCH 147/992] fix(install): dont load the colorscheme again if a
`config()` of the colorscheme also loads it. Fixes #488
---
lua/lazy/core/loader.lua | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 68f05e8..4d00a5e 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -63,7 +63,8 @@ function M.install_missing()
for _, plugin in pairs(Config.plugins) do
if not (plugin._.installed or Plugin.has_errors(plugin)) then
for _, colorscheme in ipairs(Config.options.install.colorscheme) do
- if pcall(vim.cmd.colorscheme, colorscheme) then
+ M.colorscheme(colorscheme)
+ if vim.g.colors_name or pcall(vim.cmd.colorscheme, colorscheme) then
break
end
end
From 57a3960fafc210f240a07439d1adfaba09d6ff59 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 7 Feb 2023 23:52:02 +0100
Subject: [PATCH 148/992] feat: deactivate WIP
---
lua/lazy/core/loader.lua | 109 ++++++++++++++++++++++++++++++++++-----
lua/lazy/types.lua | 2 +
2 files changed, 97 insertions(+), 14 deletions(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 4d00a5e..6c369c6 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -181,6 +181,78 @@ function M.load(plugins, reason, opts)
end
end
+---@param plugin LazyPlugin
+function M.deactivate(plugin)
+ local main = M.get_main(plugin)
+
+ if main then
+ Util.try(function()
+ local mod = require(main)
+ if mod.deactivate then
+ mod.deactivate(plugin)
+ end
+ end, "Failed to deactivate plugin " .. plugin.name)
+ end
+
+ -- execute deactivate when needed
+ if plugin._.loaded and plugin.deactivate then
+ Util.try(function()
+ plugin.deactivate(plugin)
+ end, "Failed to deactivate plugin " .. plugin.name)
+ end
+
+ -- disable handlers
+ Handler.disable(plugin)
+
+ -- remove loaded lua modules
+ Util.walkmods(plugin.dir .. "/lua", function(modname)
+ package.loaded[modname] = nil
+ package.preload[modname] = nil
+ end)
+
+ -- clear vim.g.loaded_ for plugins
+ Util.ls(plugin.dir .. "/plugin", function(_, name, type)
+ if type == "file" then
+ vim.g["loaded_" .. name:gsub("%..*", "")] = nil
+ end
+ end)
+ -- set as not loaded
+ plugin._.loaded = nil
+end
+
+--- reload a plugin
+---@param plugin LazyPlugin
+function M.reload(plugin)
+ M.deactivate(plugin)
+ local load = false -- plugin._.loaded ~= nil
+
+ -- enable handlers
+ Handler.enable(plugin)
+
+ -- run init
+ if plugin.init then
+ Util.try(function()
+ plugin.init(plugin)
+ end, "Failed to run `init` for **" .. plugin.name .. "**")
+ end
+
+ -- if this is a start plugin, load it now
+ if plugin.lazy == false then
+ load = true
+ end
+
+ for _, event in ipairs(plugin.event or {}) do
+ if event == "VimEnter" or event == "UIEnter" or event:find("VeryLazy") then
+ load = true
+ break
+ end
+ end
+
+ if load then
+ M.load(plugin, { start = "reload" })
+ end
+end
+
---@param plugin LazyPlugin
---@param reason {[string]:string}
---@param opts? {force:boolean} when force is true, we skip the cond check
@@ -242,22 +314,11 @@ function M.config(plugin)
plugin.config(plugin, opts)
end
else
- local normname = Util.normname(plugin.name)
- ---@type string[]
- local mods = {}
- for _, modname in ipairs(Cache.get_topmods(plugin.dir)) do
- mods[#mods + 1] = modname
- local modnorm = Util.normname(modname)
- -- if we found an exact match, then use that
- if modnorm == normname then
- mods = { modname }
- break
- end
- end
- if #mods == 1 then
+ local main = M.get_main(plugin)
+ if main then
fn = function()
local opts = Plugin.values(plugin, "opts", false)
- require(mods[1]).setup(opts)
+ require(main).setup(opts)
end
else
return Util.error(
@@ -268,6 +329,26 @@ function M.config(plugin)
Util.try(fn, "Failed to run `config` for " .. plugin.name)
end
+---@param plugin LazyPlugin
+function M.get_main(plugin)
+ if plugin.main then
+ return plugin.main
+ end
+ local normname = Util.normname(plugin.name)
+ ---@type string[]
+ local mods = {}
+ for _, modname in ipairs(Cache.get_topmods(plugin.dir)) do
+ mods[#mods + 1] = modname
+ local modnorm = Util.normname(modname)
+ -- if we found an exact match, then use that
+ if modnorm == normname then
+ mods = { modname }
+ break
+ end
+ end
+ return #mods == 1 and mods[1] or nil
+end
+
---@param path string
function M.packadd(path)
M.source_runtime(path, "plugin")
diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua
index 6a0c055..5f77ae1 100644
--- a/lua/lazy/types.lua
+++ b/lua/lazy/types.lua
@@ -19,6 +19,7 @@
---@class LazyPluginHooks
---@field init? fun(self:LazyPlugin) Will always be run
+---@field deactivate? fun(self:LazyPlugin) Unload/Stop a plugin
---@field config? fun(self:LazyPlugin, opts:table)|true Will be executed when loading the plugin
---@field build? string|fun(self:LazyPlugin)|(string|fun(self:LazyPlugin))[]
---@field opts? PluginOpts
@@ -40,6 +41,7 @@
---@class LazyPluginBase
---@field [1] string?
---@field name string display name and name used for plugin config files
+---@field main? string Entry module that has setup & deactivate
---@field url string?
---@field dir string
---@field enabled? boolean|(fun():boolean)
From 4272d2100af2384f4b8aba08aef4a7b9a296bce6 Mon Sep 17 00:00:00 2001
From: MurdeRM3L0DY <95099980+MurdeRM3L0DY@users.noreply.github.com>
Date: Wed, 8 Feb 2023 00:45:28 +0100
Subject: [PATCH 149/992] fix(keys): refactor retrigger mechanism (#428)
* fix keymap retrigger in operator mode
* remove unnecessary retrigger logic
we can just eval `"" .. lhs` to retrigger the mapping
* remove unused function
---------
Co-authored-by: MurdeRM3L0DY <>
---
lua/lazy/core/handler/keys.lua | 41 ++++------------------------------
1 file changed, 4 insertions(+), 37 deletions(-)
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index dd78581..bf7f4e2 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -14,42 +14,6 @@ local Loader = require("lazy.core.loader")
---@class LazyKeysHandler:LazyHandler
local M = {}
----@param feed string
-function M.replace_special(feed)
- for special, key in pairs({ leader = vim.g.mapleader or "\\", localleader = vim.g.maplocalleader or "\\" }) do
- local pattern = "<"
- for i = 1, #special do
- pattern = pattern .. "[" .. special:sub(i, i) .. special:upper():sub(i, i) .. "]"
- end
- pattern = pattern .. ">"
- feed = feed:gsub(pattern, key)
- end
- return feed
-end
-
-function M.retrigger(keys)
- local pending = ""
- while true do
- ---@type number|string
- local c = vim.fn.getchar(0)
- if c == 0 then
- break
- end
- c = type(c) == "number" and vim.fn.nr2char(c) or c
- pending = pending .. c
- end
- local op = vim.v.operator
- if op and op ~= "" and vim.api.nvim_get_mode().mode:find("o") then
- keys = "" .. op .. keys
- end
- local feed = keys .. pending
- feed = M.replace_special(feed)
- if vim.v.count ~= 0 then
- feed = vim.v.count .. feed
- end
- vim.api.nvim_input(feed)
-end
-
---@param value string|LazyKeys
function M.parse(value)
local ret = vim.deepcopy(value)
@@ -99,6 +63,8 @@ end
function M:_add(keys)
local lhs = keys[1]
local opts = M.opts(keys)
+ opts.remap = true
+ opts.expr = true
vim.keymap.set(keys.mode, lhs, function()
local plugins = self.active[keys.id]
@@ -108,8 +74,9 @@ function M:_add(keys)
Util.track({ keys = lhs })
Loader.load(plugins, { keys = lhs })
- M.retrigger(lhs)
Util.track()
+
+ return "" .. lhs
end, opts)
end
From 2451ea4e655bc60ef639ad284e69c6fca15da352 Mon Sep 17 00:00:00 2001
From: kyoh86
Date: Wed, 8 Feb 2023 15:32:29 +0900
Subject: [PATCH 150/992] feat: use "wslview" instead of "xsl-open" if it
exsits (#509)
---
lua/lazy/util.lua | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua
index 456ad83..23e32b5 100644
--- a/lua/lazy/util.lua
+++ b/lua/lazy/util.lua
@@ -25,6 +25,8 @@ function M.open(uri)
else
if vim.fn.executable("xdg-open") then
cmd = { "xdg-open", uri }
+ elseif vim.fn.executable("wslview") then
+ cmd = { "wslview", uri }
else
cmd = { "open", uri }
end
From 382c8fac56cc6c3d054736861b17c42f1a640e89 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 8 Feb 2023 06:33:17 +0000
Subject: [PATCH 151/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 849e3b4..86afc22 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 07
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 08
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From ddaffa07156a090383bd32ef88669eea1b22c11a Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 8 Feb 2023 09:33:38 +0100
Subject: [PATCH 152/992] fix(keys): replace keycodes manually
---
lua/lazy/core/handler/keys.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index bf7f4e2..f398127 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -65,6 +65,7 @@ function M:_add(keys)
local opts = M.opts(keys)
opts.remap = true
opts.expr = true
+ opts.replace_keycodes = false
vim.keymap.set(keys.mode, lhs, function()
local plugins = self.active[keys.id]
@@ -75,8 +76,7 @@ function M:_add(keys)
Util.track({ keys = lhs })
Loader.load(plugins, { keys = lhs })
Util.track()
-
- return "" .. lhs
+ return vim.api.nvim_replace_termcodes("" .. lhs, false, true, true)
end, opts)
end
From c734d941b47312baafe3e0429a5fecd25da95f5f Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 8 Feb 2023 16:00:56 +0100
Subject: [PATCH 153/992] fix(keys): feed keys instead of returning expr for
Neovim 0.8.x. Fixes #511
---
lua/lazy/core/handler/keys.lua | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index f398127..8285240 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -63,9 +63,6 @@ end
function M:_add(keys)
local lhs = keys[1]
local opts = M.opts(keys)
- opts.remap = true
- opts.expr = true
- opts.replace_keycodes = false
vim.keymap.set(keys.mode, lhs, function()
local plugins = self.active[keys.id]
@@ -76,8 +73,15 @@ function M:_add(keys)
Util.track({ keys = lhs })
Loader.load(plugins, { keys = lhs })
Util.track()
- return vim.api.nvim_replace_termcodes("" .. lhs, false, true, true)
- end, opts)
+
+ local feed = vim.api.nvim_replace_termcodes("" .. lhs, true, true, true)
+ -- insert instead of append the lhs
+ vim.api.nvim_feedkeys(feed, "i", false)
+ end, {
+ desc = opts.desc,
+ -- we do not return anything, but this is still needed to make operator pending mappings work
+ expr = true,
+ })
end
---@param keys LazyKeys
From d13fe9353594bce58a5b9fc6d7166d183e0fc035 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 9 Feb 2023 14:44:13 +0100
Subject: [PATCH 154/992] chore(main): release 9.7.0 (#505)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 16 ++++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e66b59..a2ed41b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,21 @@
# Changelog
+## [9.7.0](https://github.com/folke/lazy.nvim/compare/v9.6.0...v9.7.0) (2023-02-08)
+
+
+### Features
+
+* deactivate WIP ([57a3960](https://github.com/folke/lazy.nvim/commit/57a3960fafc210f240a07439d1adfaba09d6ff59))
+* use "wslview" instead of "xsl-open" if it exsits ([#509](https://github.com/folke/lazy.nvim/issues/509)) ([2451ea4](https://github.com/folke/lazy.nvim/commit/2451ea4e655bc60ef639ad284e69c6fca15da352))
+
+
+### Bug Fixes
+
+* **install:** dont load the colorscheme again if a `config()` of the colorscheme also loads it. Fixes [#488](https://github.com/folke/lazy.nvim/issues/488) ([49b43de](https://github.com/folke/lazy.nvim/commit/49b43def14f7e130cc27c7041ca2942142a881ed))
+* **keys:** feed keys instead of returning expr for Neovim 0.8.x. Fixes [#511](https://github.com/folke/lazy.nvim/issues/511) ([c734d94](https://github.com/folke/lazy.nvim/commit/c734d941b47312baafe3e0429a5fecd25da95f5f))
+* **keys:** refactor retrigger mechanism ([#428](https://github.com/folke/lazy.nvim/issues/428)) ([4272d21](https://github.com/folke/lazy.nvim/commit/4272d2100af2384f4b8aba08aef4a7b9a296bce6))
+* **keys:** replace keycodes manually ([ddaffa0](https://github.com/folke/lazy.nvim/commit/ddaffa07156a090383bd32ef88669eea1b22c11a))
+
## [9.6.0](https://github.com/folke/lazy.nvim/compare/v9.5.1...v9.6.0) (2023-02-07)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 62ff3d7..4d9523f 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -146,7 +146,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.6.0" -- x-release-please-version
+M.version = "9.7.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 273081443471cbc52c327bcb99614c32f247998d Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 9 Feb 2023 13:45:04 +0000
Subject: [PATCH 155/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 86afc22..c872dec 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 08
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 09
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From a1471103902a9836d88732eeeeabd11d00a2cb3e Mon Sep 17 00:00:00 2001
From: Yahir Eduardo Bravo Tafur
Date: Thu, 9 Feb 2023 12:02:40 -0500
Subject: [PATCH 156/992] fix(cmd): fix Error when trigger on range defined
command that doesn't support count (#519)
---
lua/lazy/core/handler/cmd.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/handler/cmd.lua b/lua/lazy/core/handler/cmd.lua
index 142eda8..6ee52ad 100644
--- a/lua/lazy/core/handler/cmd.lua
+++ b/lua/lazy/core/handler/cmd.lua
@@ -19,7 +19,7 @@ function M:_add(cmd)
bang = event.bang or nil,
mods = event.smods,
args = event.fargs,
- count = event.count >= 0 and event.count or nil,
+ count = event.count >= 0 and event.range == 0 and event.count or nil,
}
if event.range == 1 then
From e28555950f8ceb52e86533df6df333dcd55fba04 Mon Sep 17 00:00:00 2001
From: dundargoc <33953936+dundargoc@users.noreply.github.com>
Date: Thu, 9 Feb 2023 22:10:36 +0100
Subject: [PATCH 157/992] ci: fix typo. (#523)
---
.github/ISSUE_TEMPLATE/bug_report.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index c7a92d3..4a77601 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -16,7 +16,7 @@ body:
required: true
- label: I have searched the existing issues of lazy.nvim
required: true
- - label: I have searched the exsiting issues of plugins related to this issue
+ - label: I have searched the existing issues of plugins related to this issue
required: true
- type: input
attributes:
From c83d2aeb27fce9cf9f14e779e77a85c63fc3d2c9 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 10 Feb 2023 17:47:25 +0100
Subject: [PATCH 158/992] fix(loader): don't deactivate when not loaded
---
lua/lazy/core/loader.lua | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 6c369c6..e826654 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -183,6 +183,10 @@ end
---@param plugin LazyPlugin
function M.deactivate(plugin)
+ if not plugin._.loaded then
+ return
+ end
+
local main = M.get_main(plugin)
if main then
@@ -195,7 +199,7 @@ function M.deactivate(plugin)
end
-- execute deactivate when needed
- if plugin._.loaded and plugin.deactivate then
+ if plugin.deactivate then
Util.try(function()
plugin.deactivate(plugin)
end, "Failed to deactivate plugin " .. plugin.name)
From bab744565e9d8d743b1889c66707aa2e8018ae86 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 10 Feb 2023 16:48:16 +0000
Subject: [PATCH 159/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index c872dec..d46aa7e 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 09
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 10
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From bc978ca9be96b75330336a0427771addaa1ccd50 Mon Sep 17 00:00:00 2001
From: ryuryu-ymj <33318253+ryuryu-ymj@users.noreply.github.com>
Date: Sat, 11 Feb 2023 17:03:10 +0900
Subject: [PATCH 160/992] fix(icons): replace an obsolete Nerd icon (#529)
---
lua/lazy/core/config.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 4d9523f..c1a236f 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -53,7 +53,7 @@ M.defaults = {
init = " ",
import = " ",
keys = " ",
- lazy = "鈴 ",
+ lazy = " ",
loaded = "●",
not_loaded = "○",
plugin = " ",
From b5eb07e728fb17d6e2a469b5032b920ec7bd470d Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sat, 11 Feb 2023 08:03:55 +0000
Subject: [PATCH 161/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index d46aa7e..60087b6 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 10
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 11
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 4917222c7e5c924bf7471b72a5e2d3e661530b40 Mon Sep 17 00:00:00 2001
From: kyoh86
Date: Sat, 11 Feb 2023 17:04:59 +0900
Subject: [PATCH 162/992] fix(util): executable checks for `Util.open` (#528)
---
lua/lazy/util.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua
index 23e32b5..743a679 100644
--- a/lua/lazy/util.lua
+++ b/lua/lazy/util.lua
@@ -23,9 +23,9 @@ function M.open(uri)
elseif vim.fn.has("macunix") == 1 then
cmd = { "open", uri }
else
- if vim.fn.executable("xdg-open") then
+ if vim.fn.executable("xdg-open") == 1 then
cmd = { "xdg-open", uri }
- elseif vim.fn.executable("wslview") then
+ elseif vim.fn.executable("wslview") == 1 then
cmd = { "wslview", uri }
else
cmd = { "open", uri }
From 0d3f2c40421f4774c70f631d7b7023f57cba66cd Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Sun, 12 Feb 2023 12:56:42 +0100
Subject: [PATCH 163/992] feat(git): `Plugin.submodules = false` will now skip
fetching git submodules
---
README.md | 1 +
lua/lazy/manage/task/git.lua | 17 +++++++++++++----
lua/lazy/types.lua | 1 +
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index b2fa8a3..450d8f0 100644
--- a/README.md
+++ b/README.md
@@ -99,6 +99,7 @@ require("lazy").setup({
| **commit** | `string?` | Commit of the repository |
| **version** | `string?` | Version to use from the repository. Full [Semver](https://devhints.io/semver) ranges are supported |
| **pin** | `boolean?` | When `true`, this plugin will not be included in updates |
+| `submodules` | `boolean?` | When false, git submodules will not be fetched. Defaults to `true` |
| **event** | `string?` or `string[]` or `fun(self:LazyPlugin, event:string[]):string[]` | Lazy-load on event. Events can be specified as `BufEnter` or with a pattern like `BufEnter *.lua` |
| **cmd** | `string?` or `string[]` or `fun(self:LazyPlugin, cmd:string[]):string[]` | Lazy-load on command |
| **ft** | `string?` or `string[]` or `fun(self:LazyPlugin, ft:string[]):string[]` | Lazy-load on filetype |
diff --git a/lua/lazy/manage/task/git.lua b/lua/lazy/manage/task/git.lua
index 377b3ef..3882362 100644
--- a/lua/lazy/manage/task/git.lua
+++ b/lua/lazy/manage/task/git.lua
@@ -70,10 +70,11 @@ M.clone = {
args[#args + 1] = "--filter=blob:none"
end
- vim.list_extend(args, {
- "--recurse-submodules",
- "--progress",
- })
+ if self.plugin.submodules ~= false then
+ args[#args + 1] = "--recurse-submodules"
+ end
+
+ args[#args + 1] = "--progress"
if self.plugin.branch then
vim.list_extend(args, { "-b", self.plugin.branch })
@@ -158,6 +159,10 @@ M.fetch = {
"--progress",
}
+ if self.plugin.submodules == false then
+ table.remove(args, 2)
+ end
+
self:spawn("git", {
args = args,
cwd = self.plugin.dir,
@@ -209,6 +214,10 @@ M.checkout = {
"--recurse-submodules",
}
+ if self.plugin.submodules == false then
+ table.remove(args, 3)
+ end
+
if lock then
table.insert(args, lock.commit)
elseif target.tag then
diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua
index 5f77ae1..067450a 100644
--- a/lua/lazy/types.lua
+++ b/lua/lazy/types.lua
@@ -37,6 +37,7 @@
---@field commit? string
---@field version? string
---@field pin? boolean
+---@field submodules? boolean Defaults to true
---@class LazyPluginBase
---@field [1] string?
From 06f835d0b4b62d9d26fe0ec4190b981f2f5632d2 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sun, 12 Feb 2023 11:57:29 +0000
Subject: [PATCH 164/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 60087b6..ce6590e 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 11
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 12
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
@@ -131,6 +131,7 @@ PLUGIN SPEC *lazy.nvim-plugin-spec*
│**commit** │string? │Commit of the repository │
│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
│**pin** │boolean? │When true, this plugin will not be included in updates │
+│submodules │boolean? │When false, git submodules will not be fetched. Defaults to true │
│**event** │string? or string[] or fun(self:LazyPlugin, event:string[]):string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
│**cmd** │string? or string[] or fun(self:LazyPlugin, cmd:string[]):string[] │Lazy-load on command │
│**ft** │string? or string[] or fun(self:LazyPlugin, ft:string[]):string[] │Lazy-load on filetype │
From 462633bae11255133f099163dda17180b3a6dc27 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 13 Feb 2023 12:01:56 +0100
Subject: [PATCH 165/992] perf: new file-based cache that ensures correct rtp
order (#532)
* perf: new file-based cache that ensures rtp is alweays correct and will cache all files, including those after startup
* refactor: new cache
* test: fix tests
* fix(cache): cache file names on Windows
* feat(cache): allow to disable the cache
* docs: updated cache settings
---
README.md | 10 +-
lua/lazy/core/cache.lua | 728 ++++++++++++-----------------------
lua/lazy/core/config.lua | 6 +-
lua/lazy/core/loader.lua | 28 +-
lua/lazy/core/util.lua | 39 +-
lua/lazy/docs.lua | 5 -
lua/lazy/init.lua | 5 +-
lua/lazy/manage/reloader.lua | 15 +-
lua/lazy/view/render.lua | 31 +-
tests/core/util_spec.lua | 36 +-
10 files changed, 354 insertions(+), 549 deletions(-)
diff --git a/README.md b/README.md
index 450d8f0..37fa84f 100644
--- a/README.md
+++ b/README.md
@@ -347,7 +347,7 @@ return {
init = " ",
import = " ",
keys = " ",
- lazy = "鈴 ",
+ lazy = " ",
loaded = "●",
not_loaded = "○",
plugin = " ",
@@ -409,14 +409,6 @@ return {
performance = {
cache = {
enabled = true,
- path = vim.fn.stdpath("cache") .. "/lazy/cache",
- -- Once one of the following events triggers, caching will be disabled.
- -- To cache all modules, set this to `{}`, but that is not recommended.
- -- The default is to disable on:
- -- * VimEnter: not useful to cache anything else beyond startup
- -- * BufReadPre: this will be triggered early when opening a file from the command line directly
- disable_events = { "UIEnter", "BufReadPre" },
- ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
},
reset_packpath = true, -- reset the package path to improve startup time
rtp = {
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 3f30ff2..89d5a4a 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -1,240 +1,264 @@
local ffi = require("ffi")
----@diagnostic disable-next-line: no-unknown
local uv = vim.loop
local M = {}
-M.dirty = false
-M.VERSION = "1" .. jit.version
-
----@class LazyCacheConfig
-M.config = {
- enabled = true,
- path = vim.fn.stdpath("cache") .. "/lazy/cache",
- -- Once one of the following events triggers, caching will be disabled.
- -- To cache all modules, set this to `{}`, but that is not recommended.
- -- The default is to disable on:
- -- * VimEnter: not useful to cache anything else beyond startup
- -- * BufReadPre: this will be triggered early when opening a file from the command line directly
- disable_events = { "UIEnter", "BufReadPre" },
- ttl = 3600 * 24 * 5, -- keep unused modules for up to 5 days
-}
-M.debug = false
-
----@type CacheHash
-local cache_hash
---@alias CacheHash {mtime: {sec:number, nsec:number}, size:number}
----@alias CacheEntry {hash:CacheHash, modpath:string, chunk:string, used:number}
----@type table
-M.cache = {}
-M.enabled = true
----@type string[]
-M.rtp = nil
-M.rtp_total = 0
-M.stats = {
- find = { total = 0, time = 0, rtp = 0, unloaded = 0, index = 0, stat = 0, not_found = 0 },
- autoload = { total = 0, time = 0 },
+---@alias CacheEntry {hash:CacheHash, modpath:string, chunk:string}
+
+---@class CacheFindOpts
+---@field rtp? boolean Search for modname in the runtime path (defaults to `true`)
+---@field patterns? string[] Paterns to use (defaults to `{"/init.lua", ".lua"}`)
+---@field paths? string[] Extra paths to search for modname
+
+M.VERSION = 1
+M.path = vim.fn.stdpath("cache") .. "/lazy/luac"
+M.enabled = false
+M.stats = { total = 0, time = 0, index = 0, stat = 0, not_found = 0 }
+
+---@class ModuleCache
+---@field _rtp string[]
+---@field _rtp_key string
+local Cache = {
+ ---@type table>
+ _topmods = {},
+ _loadfile = loadfile,
}
-M.me = debug.getinfo(1, "S").source:sub(2)
-M.me = vim.fn.fnamemodify(M.me, ":p:h:h:h:h"):gsub("\\", "/")
----@type table
-M.topmods = { lazy = { M.me } }
----@type table
-M.indexed = { [M.me] = { "lazy" } }
-M.indexed_unloaded = false
-M.indexed_rtp = 0
--- selene:allow(global_usage)
-M._loadfile = _G.loadfile
--- checks whether the cached modpath is still valid
-function M.check_path(modname, modpath)
- -- HACK: never return packer paths
- if modpath:find("/site/pack/packer/", 1, true) then
- return false
- end
-
- -- check rtp excluding plugins. This is a very small list, so should be fast
- for _, path in ipairs(M.get_rtp()) do
- if modpath:find(path .. "/", 1, true) == 1 then
- return true
+-- slightly faster/different version than vim.fs.normalize
+-- we also need to have it here, since the cache will load vim.fs
+---@private
+function Cache.normalize(path)
+ if path:sub(1, 1) == "~" then
+ local home = vim.loop.os_homedir()
+ if home:sub(-1) == "\\" or home:sub(-1) == "/" then
+ home = home:sub(1, -2)
end
+ path = home .. path:sub(2)
end
-
- -- the correct lazy path should be part of rtp.
- -- so if we get here, this is folke using the local dev instance ;)
- if modname and (modname == "lazy" or modname:sub(1, 5) == "lazy.") then
- return false
- end
-
- return modname and M.check_autoload(modname, modpath)
+ path = path:gsub("\\", "/"):gsub("/+", "/")
+ return path:sub(-1) == "/" and path:sub(1, -2) or path
end
-function M.check_autoload(modname, modpath)
- local start = uv.hrtime()
- M.stats.autoload.total = M.stats.autoload.total + 1
-
- -- check plugins. Again fast, since we check the plugin name from the path.
- -- only needed when the plugin mod has been loaded
- ---@type LazyCorePlugin
- local Plugin = package.loaded["lazy.core.plugin"]
- if Plugin then
- local plugin = Plugin.find(modpath)
- if plugin and modpath:find(plugin.dir, 1, true) == 1 then
- -- we're not interested in loader time, so calculate delta here
- M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start
- -- don't load if we're loading specs or if the plugin is already loaded
- if not (Plugin.loading or plugin._.loaded) then
- if plugin.module == false then
- error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
- end
- require("lazy.core.loader").load(plugin, { require = modname })
+---@private
+function Cache.get_rtp()
+ if vim.in_fast_event() then
+ return Cache._rtp or {}
+ end
+ local key = vim.go.rtp
+ if key ~= Cache._rtp_key then
+ Cache._rtp = {}
+ for _, path in ipairs(vim.api.nvim_get_runtime_file("", true)) do
+ path = Cache.normalize(path)
+ -- skip after directories
+ if path:sub(-6, -1) ~= "/after" then
+ Cache._rtp[#Cache._rtp + 1] = path
end
- return true
+ end
+ Cache._rtp_key = key
+ end
+ return Cache._rtp
+end
+
+---@param name string can be a module name, or a file name
+---@private
+function Cache.cache_file(name)
+ return M.path .. "/" .. name:gsub("[/\\:]", "%%") .. "c"
+end
+
+---@param entry CacheEntry
+---@private
+function Cache.write(name, entry)
+ local cname = Cache.cache_file(name)
+ local f = assert(uv.fs_open(cname, "w", 438))
+ local header = {
+ M.VERSION,
+ entry.hash.size,
+ entry.hash.mtime.sec,
+ entry.hash.mtime.nsec,
+ #entry.modpath,
+ }
+ uv.fs_write(f, ffi.string(ffi.new("const uint32_t[5]", header), 20))
+ uv.fs_write(f, entry.modpath)
+ uv.fs_write(f, entry.chunk)
+ uv.fs_close(f)
+end
+
+---@return CacheEntry?
+---@private
+function Cache.read(name)
+ local cname = Cache.cache_file(name)
+ local f = uv.fs_open(cname, "r", 438)
+ if f then
+ local hash = uv.fs_fstat(f) --[[@as CacheHash]]
+ local data = uv.fs_read(f, hash.size, 0) --[[@as string]]
+ uv.fs_close(f)
+
+ ---@type integer[]|{[0]:integer}
+ local header = ffi.cast("uint32_t*", ffi.new("const char[20]", data:sub(1, 20)))
+ if header[0] ~= M.VERSION then
+ return
+ end
+ local modpath = data:sub(21, 20 + header[4])
+ return {
+ hash = { size = header[1], mtime = { sec = header[2], nsec = header[3] } },
+ chunk = data:sub(20 + header[4] + 1),
+ modpath = modpath,
+ }
+ end
+end
+
+---@param modname string
+---@private
+function Cache.loader(modname)
+ modname = modname:gsub("/", ".")
+ local modpath, hash = Cache.find(modname)
+ if modpath then
+ return Cache.load(modpath, { hash = hash })
+ end
+ return "module " .. modname .. " not found"
+end
+
+---@param filename? string
+---@param mode? "b"|"t"|"bt"
+---@param env? table
+---@return function?, string? error_message
+---@private
+function Cache.loadfile(filename, mode, env)
+ filename = Cache.normalize(filename)
+ return Cache.load(filename, { mode = mode, env = env })
+end
+
+---@param h1 CacheHash
+---@param h2 CacheHash
+---@private
+function Cache.eq(h1, h2)
+ return h1 and h2 and h1.size == h2.size and h1.mtime.sec == h2.mtime.sec and h1.mtime.nsec == h2.mtime.nsec
+end
+
+---@param modpath string
+---@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table}
+---@return function?, string? error_message
+---@private
+function Cache.load(modpath, opts)
+ opts = opts or {}
+ local hash = opts.hash or uv.fs_stat(modpath)
+ if not hash then
+ -- trigger correct error
+ return Cache._loadfile(modpath)
+ end
+
+ ---@type function?, string?
+ local chunk, err
+ local entry = Cache.read(modpath)
+ if entry and Cache.eq(entry.hash, hash) then
+ -- found in cache and up to date
+ chunk, err = loadstring(entry.chunk --[[@as string]], "@" .. entry.modpath)
+ if not (err and err:find("cannot load incompatible bytecode", 1, true)) then
+ return chunk, err
end
end
- M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start
- return false
+ entry = { hash = hash, modpath = modpath }
+
+ chunk, err = Cache._loadfile(entry.modpath)
+ if chunk then
+ entry.chunk = string.dump(chunk)
+ Cache.write(modpath, entry)
+ end
+ return chunk, err
+end
+
+---@param modname string
+---@param opts? CacheFindOpts
+---@return string? modpath, CacheHash? hash
+function Cache.find(modname, opts)
+ opts = opts or {}
+ local start = uv.hrtime()
+ M.stats.total = M.stats.total + 1
+ modname = modname:gsub("/", ".")
+ local basename = modname:gsub("%.", "/")
+ local idx = modname:find(".", 1, true)
+ local topmod = idx and modname:sub(1, idx - 1) or modname
+
+ -- OPTIM: search for a directory first when topmod == modname
+ local patterns = opts.patterns or (topmod == modname and { "/init.lua", ".lua" } or { ".lua", "/init.lua" })
+ local rtp = opts.rtp ~= false and Cache.get_rtp() or {}
+ if opts.paths then
+ rtp = vim.deepcopy(rtp)
+ for _, dir in ipairs(opts.paths) do
+ rtp[#rtp + 1] = Cache.normalize(dir)
+ end
+ end
+ for p, pattern in ipairs(patterns) do
+ patterns[p] = "/lua/" .. basename .. pattern
+ end
+
+ for _, path in ipairs(rtp) do
+ if M.lsmod(path)[topmod] then
+ for _, pattern in ipairs(patterns) do
+ local modpath = path .. pattern
+ M.stats.stat = M.stats.stat + 1
+ local hash = uv.fs_stat(modpath)
+ if hash then
+ M.stats.time = M.stats.time + uv.hrtime() - start
+ return modpath, hash
+ end
+ end
+ end
+ end
+
+ -- module not found
+ M.stats.not_found = M.stats.not_found + 1
+ M.stats.time = M.stats.time + uv.hrtime() - start
+end
+
+--- Resets the topmods cache for the path
+---@param path string
+function M.reset(path)
+ Cache._topmods[Cache.normalize(path)] = nil
+end
+
+function M.enable()
+ if M.enabled then
+ return
+ end
+ M.enabled = true
+ vim.fn.mkdir(vim.fn.fnamemodify(M.path, ":p"), "p")
+ -- selene: allow(global_usage)
+ _G.loadfile = Cache.loadfile
+ table.insert(package.loaders, 2, Cache.loader)
end
function M.disable()
if not M.enabled then
return
end
- -- selene:allow(global_usage)
- _G.loadfile = M._loadfile
M.enabled = false
- if M.debug and vim.tbl_count(M.topmods) > 1 then
- M.log(M.topmods, { level = vim.log.levels.WARN, title = "topmods" })
- end
- if M.debug and false then
- local stats = vim.deepcopy(M.stats)
- stats.time = (stats.time or 0) / 1e6
- stats.find.time = (stats.find.time or 0) / 1e6
- stats.autoload.time = (stats.autoload.time or 0) / 1e6
- M.log(stats, { title = "stats" })
- end
-end
-
----@param msg string|table
----@param opts? LazyNotifyOpts
-function M.log(msg, opts)
- if M.debug then
- msg = vim.deepcopy(msg)
- vim.schedule(function()
- require("lazy.core.util").debug(msg, opts)
- end)
- end
-end
-
-function M.check_loaded(modname)
+ -- selene: allow(global_usage)
+ _G.loadfile = Cache._loadfile
---@diagnostic disable-next-line: no-unknown
- local mod = package.loaded[modname]
- if type(mod) == "table" then
- return function()
- return mod
+ for l, loader in ipairs(package.loaders) do
+ if loader == Cache.loader then
+ table.remove(package.loaders, l)
end
end
end
----@param modname string
----@return fun()|string
-function M.loader(modname)
- modname = modname:gsub("/", ".")
- local entry = M.cache[modname]
-
- local chunk, err
- if entry then
- if M.check_path(modname, entry.modpath) then
- M.stats.find.total = M.stats.find.total + 1
- chunk, err = M.load(modname, entry.modpath)
- else
- M.cache[modname] = nil
- M.dirty = true
- end
- end
- if not chunk then
- -- find the modpath and load the module
- local modpath = M.find(modname)
- if modpath then
- M.check_autoload(modname, modpath)
- if M.enabled then
- chunk, err = M.load(modname, modpath)
- else
- chunk = M.check_loaded(modname)
- if not chunk then
- chunk, err = M._loadfile(modpath)
- end
+-- Return the top-level `/lua/*` modules for this path
+---@return string[]
+function M.lsmod(path)
+ if not Cache._topmods[path] then
+ M.stats.index = M.stats.index + 1
+ Cache._topmods[path] = {}
+ local handle = vim.loop.fs_scandir(path .. "/lua")
+ while handle do
+ local name, t = vim.loop.fs_scandir_next(handle)
+ if not name then
+ break
end
- end
- end
- return chunk or err or ("module " .. modname .. " not found")
-end
-
----@param modpath string
----@return any, string?
-function M.loadfile(modpath)
- modpath = modpath:gsub("\\", "/")
- return M.load(modpath, modpath)
-end
-
----@param modkey string
----@param modpath string
----@return function?, string? error_message
-function M.load(modkey, modpath)
- local chunk, err
- chunk = M.check_loaded(modkey)
- if chunk then
- return chunk
- end
- modpath = modpath:gsub("\\", "/")
- local hash = M.hash(modpath)
- if not hash then
- -- trigger correct error
- return M._loadfile(modpath)
- end
-
- local entry = M.cache[modkey]
- if entry then
- entry.modpath = modpath
- entry.used = os.time()
- if M.eq(entry.hash, hash) then
- -- found in cache and up to date
- chunk, err = loadstring(entry.chunk --[[@as string]], "@" .. entry.modpath)
- if not (err and err:find("cannot load incompatible bytecode", 1, true)) then
- return chunk, err
- end
- end
- else
- entry = { hash = hash, modpath = modpath, used = os.time() }
- M.cache[modkey] = entry
- end
- entry.hash = hash
-
- if M.debug then
- M.log("`" .. modpath .. "`", { level = vim.log.levels.WARN, title = "Cache.load" })
- end
-
- chunk, err = M._loadfile(entry.modpath)
- M.dirty = true
- if chunk then
- entry.chunk = string.dump(chunk)
- else
- M.cache[modkey] = nil
- end
- return chunk, err
-end
-
--- index the top-level lua modules for this path
-function M._index(path)
- if not M.indexed[path] and path:sub(-6, -1) ~= "/after" then
- M.stats.find.index = M.stats.find.index + 1
- ---@type LazyUtilCore
- local Util = package.loaded["lazy.core.util"]
- if not Util then
- return false
- end
- M.indexed[path] = {}
- Util.ls(path .. "/lua", function(_, name, t)
+ -- HACK: type is not always returned due to a bug in luv
+ t = t or vim.loop.fs_stat(path .. "/" .. name).type
+ ---@type string
local topname
if name:sub(-4) == ".lua" then
topname = name:sub(1, -5)
@@ -242,283 +266,41 @@ function M._index(path)
topname = name
end
if topname then
- M.topmods[topname] = M.topmods[topname] or {}
- if not vim.tbl_contains(M.topmods[topname], path) then
- table.insert(M.topmods[topname], path)
- end
- if not vim.tbl_contains(M.indexed[path], topname) then
- table.insert(M.indexed[path], topname)
- end
- end
- end)
- return true
- end
- return false
-end
-
-function M.get_topmods(path)
- M._index(path)
- return M.indexed[path] or {}
-end
-
----@param modname string
----@return string?
-function M.find_root(modname)
- if M.cache[modname] then
- -- check if modname is in cache
- local modpath = M.cache[modname].modpath
- if M.check_path(modname, modpath) and uv.fs_stat(modpath) then
- local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
- return root
- end
- else
- -- in case modname is just a directory and not a real mod,
- -- check for any children in the cache
- for child, entry in pairs(M.cache) do
- if child:find(modname, 1, true) == 1 then
- if M.check_path(child, entry.modpath) and uv.fs_stat(entry.modpath) then
- local basename = modname:gsub("%.", "/")
- local childbase = child:gsub("%.", "/")
- local ret = entry.modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
- local idx = assert(ret:find(childbase, 1, true))
- return ret:sub(1, idx - 1) .. basename
- end
+ Cache._topmods[path][topname] = true
end
end
end
-
- -- not found in cache, so find the root with the special pattern
- local modpath = M.find(modname, { patterns = { "" } })
- if modpath then
- local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
- return root
- end
+ return Cache._topmods[path]
end
---@param modname string
----@param opts? {patterns?:string[]}
----@return string?
+---@param opts? CacheFindOpts
+---@return string? modpath
function M.find(modname, opts)
- opts = opts or {}
-
- M.stats.find.total = M.stats.find.total + 1
- local start = uv.hrtime()
- local basename = modname:gsub("%.", "/")
- local idx = modname:find(".", 1, true)
- local topmod = idx and modname:sub(1, idx - 1) or modname
-
- -- search for a directory first when topmod == modname
- local patterns = topmod == modname and { "/init.lua", ".lua" } or { ".lua", "/init.lua" }
-
- if opts.patterns then
- vim.list_extend(patterns, opts.patterns)
- end
-
- -- check top-level mods to find the module
- local function _find()
- for _, toppath in ipairs(M.topmods[topmod] or {}) do
- for _, pattern in ipairs(patterns) do
- local path = toppath .. "/lua/" .. basename .. pattern
- M.stats.find.stat = M.stats.find.stat + 1
- if uv.fs_stat(path) then
- return path
- end
- end
- end
- end
-
- local modpath = _find()
- if not modpath then
- -- update rtp
- local rtp = M.list_rtp()
- if #rtp ~= M.indexed_rtp then
- M.indexed_rtp = #rtp
- local updated = false
- for _, path in ipairs(rtp) do
- updated = M._index(path) or updated
- end
- if updated then
- modpath = _find()
- end
- end
-
- -- update unloaded
- if not modpath and not M.indexed_unloaded then
- M.indexed_unloaded = true
- local updated = false
- ---@type LazyCoreConfig
- local Config = package.loaded["lazy.core.config"]
- if Config and Config.spec then
- for _, plugin in pairs(Config.spec.plugins) do
- if not (M.indexed[plugin.dir] or plugin._.loaded or plugin.module == false) then
- updated = M._index(plugin.dir) or updated
- end
- end
- end
- if updated then
- modpath = _find()
- end
- end
-
- -- module not found
- if not modpath then
- M.stats.find.not_found = M.stats.find.not_found + 1
- end
- end
-
- M.stats.find.time = M.stats.find.time + uv.hrtime() - start
+ local modpath = Cache.find(modname, opts)
return modpath
end
--- returns the cached RTP excluding plugin dirs
-function M.get_rtp()
- local rtp = M.list_rtp()
- if not M.rtp or #rtp ~= M.rtp_total then
- M.rtp_total = #rtp
- M.rtp = {}
- ---@type table
- local skip = {}
- -- only skip plugins once Config has been setup
- ---@type LazyCoreConfig
- local Config = package.loaded["lazy.core.config"]
- if Config then
- for _, plugin in pairs(Config.plugins) do
- if plugin.name ~= "lazy.nvim" then
- skip[plugin.dir] = true
- end
- end
- end
- for _, path in ipairs(rtp) do
- ---@type string
- path = path:gsub("\\", "/")
- if not skip[path] and not path:find("after/?$") then
- M.rtp[#M.rtp + 1] = path
- end
- end
+function M.inspect()
+ local function ms(nsec)
+ return math.floor(nsec / 1e6 * 1000 + 0.5) / 1000 .. "ms"
end
- return M.rtp
-end
-
-function M.list_rtp()
- return vim.api.nvim_get_runtime_file("", true)
-end
-
----@param opts? LazyConfig
-function M.setup(opts)
- -- no fancy deep extend here. just set the options
- if opts and opts.performance and opts.performance.cache then
- ---@diagnostic disable-next-line: no-unknown
- for k, v in pairs(opts.performance.cache) do
- ---@diagnostic disable-next-line: no-unknown
- M.config[k] = v
- end
+ local props = {
+ { "total", M.stats.total, "Number" },
+ { "time", ms(M.stats.time), "Bold" },
+ { "avg time", ms(M.stats.time / M.stats.total), "Bold" },
+ { "index", M.stats.index, "Number" },
+ { "fs_stat", M.stats.stat, "Number" },
+ { "not found", M.stats.not_found, "Number" },
+ }
+ local chunks = {} ---@type string[][]
+ for _, prop in ipairs(props) do
+ chunks[#chunks + 1] = { "* " .. prop[1] .. ": " }
+ chunks[#chunks + 1] = { tostring(prop[2]) .. "\n", prop[3] }
end
- M.debug = opts and opts.debug
- M.enabled = M.config.enabled
-
- if M.enabled then
- table.insert(package.loaders, 2, M.loader)
- M.load_cache()
- -- selene:allow(global_usage)
- _G.loadfile = M.loadfile
- if #M.config.disable_events > 0 then
- vim.api.nvim_create_autocmd(M.config.disable_events, { once = true, callback = M.disable })
- end
- else
- -- we need to always add the loader since this will autoload unloaded modules
- table.insert(package.loaders, M.loader)
- end
-
- return M
+ vim.api.nvim_echo(chunks, true, {})
end
----@return CacheHash?
-function M.hash(file)
- local ok, ret = pcall(uv.fs_stat, file)
- return ok and ret or nil
-end
-
----@param h1 CacheHash
----@param h2 CacheHash
-function M.eq(h1, h2)
- return h1 and h2 and h1.size == h2.size and h1.mtime.sec == h2.mtime.sec and h1.mtime.nsec == h2.mtime.nsec
-end
-
-function M.save_cache()
- vim.fn.mkdir(vim.fn.fnamemodify(M.config.path, ":p:h"), "p")
- local f = assert(uv.fs_open(M.config.path, "w", 438))
- uv.fs_write(f, M.VERSION)
- uv.fs_write(f, "\0")
- for modname, entry in pairs(M.cache) do
- if entry.used > os.time() - M.config.ttl then
- entry.modname = modname
- local header = {
- entry.hash.size,
- entry.hash.mtime.sec,
- entry.hash.mtime.nsec,
- #modname,
- #entry.chunk,
- #entry.modpath,
- entry.used,
- }
- uv.fs_write(f, ffi.string(ffi.new("const uint32_t[7]", header), 28))
- uv.fs_write(f, modname)
- uv.fs_write(f, entry.chunk)
- uv.fs_write(f, entry.modpath)
- end
- end
- uv.fs_close(f)
-end
-
-function M.load_cache()
- M.cache = {}
- local f = uv.fs_open(M.config.path, "r", 438)
- if f then
- cache_hash = uv.fs_fstat(f) --[[@as CacheHash]]
- local data = uv.fs_read(f, cache_hash.size, 0) --[[@as string]]
- uv.fs_close(f)
-
- local zero = data:find("\0", 1, true)
- if not zero then
- return
- end
-
- if M.VERSION ~= data:sub(1, zero - 1) then
- return
- end
-
- local offset = zero + 1
- while offset + 1 < #data do
- local header = ffi.cast("uint32_t*", ffi.new("const char[28]", data:sub(offset, offset + 27)))
- offset = offset + 28
- local modname = data:sub(offset, offset + header[3] - 1)
- offset = offset + header[3]
- local chunk = data:sub(offset, offset + header[4] - 1)
- offset = offset + header[4]
- local file = data:sub(offset, offset + header[5] - 1)
- offset = offset + header[5]
- M.cache[modname] = {
- hash = { size = header[0], mtime = { sec = header[1], nsec = header[2] } },
- chunk = chunk,
- modpath = file,
- used = header[6],
- }
- end
- end
-end
-
-function M.autosave()
- vim.api.nvim_create_autocmd("VimLeavePre", {
- callback = function()
- if M.dirty then
- local hash = M.hash(M.config.path)
- -- abort when the file was changed in the meantime
- if hash == nil or M.eq(cache_hash, hash) then
- M.save_cache()
- end
- end
- end,
- })
-end
+M._Cache = Cache
return M
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index c1a236f..bc8257b 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -113,8 +113,9 @@ M.defaults = {
notify = true, -- get a notification when changes are found
},
performance = {
- ---@type LazyCacheConfig
- cache = nil,
+ cache = {
+ enabled = true,
+ },
reset_packpath = true, -- reset the package path to improve startup time
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
@@ -226,7 +227,6 @@ function M.setup(opts)
pattern = "VeryLazy",
once = true,
callback = function()
- require("lazy.core.cache").autosave()
require("lazy.view.commands").setup()
if M.options.change_detection.enabled then
require("lazy.manage.reloader").enable()
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index e826654..0f1b977 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -72,7 +72,7 @@ function M.install_missing()
-- remove and installed plugins from indexed, so cache will index again
for _, p in pairs(Config.plugins) do
if p._.installed then
- Cache.indexed[p.dir] = nil
+ Cache.reset(p.dir)
end
end
-- reload plugins
@@ -341,7 +341,7 @@ function M.get_main(plugin)
local normname = Util.normname(plugin.name)
---@type string[]
local mods = {}
- for _, modname in ipairs(Cache.get_topmods(plugin.dir)) do
+ for modname, _ in pairs(Cache.lsmod(plugin.dir)) do
mods[#mods + 1] = modname
local modnorm = Util.normname(modname)
-- if we found an exact match, then use that
@@ -450,4 +450,28 @@ function M.colorscheme(name)
end
end
+---@param modname string
+function M.loader(modname)
+ local modpath = Cache.find(modname, { rtp = false, paths = Util.get_unloaded_rtp(modname) })
+ if modpath then
+ local plugin = Plugin.find(modpath)
+ if plugin and modpath:find(plugin.dir, 1, true) == 1 then
+ -- don't load if we're loading specs or if the plugin is already loaded
+ if not (Plugin.loading or plugin._.loaded) then
+ if plugin.module == false then
+ error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
+ end
+ M.load(plugin, { require = modname })
+ end
+ local mod = package.loaded[modname]
+ if type(mod) == "table" then
+ return function()
+ return mod
+ end
+ end
+ return loadfile(modpath)
+ end
+ end
+end
+
return M
diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
index fd2cce4..42325dd 100644
--- a/lua/lazy/core/util.lua
+++ b/lua/lazy/core/util.lua
@@ -217,11 +217,46 @@ function M.walkmods(root, fn, modname)
end)
end
+---@param modname string
+function M.get_unloaded_rtp(modname)
+ modname = modname:gsub("/", ".")
+ local idx = modname:find(".", 1, true)
+ local topmod = idx and modname:sub(1, idx - 1) or modname
+ topmod = M.normname(topmod)
+
+ local rtp = {}
+ local Config = require("lazy.core.config")
+ if Config.spec then
+ for _, plugin in pairs(Config.spec.plugins) do
+ if not (plugin._.loaded or plugin.module == false) then
+ if topmod == M.normname(plugin.name) then
+ table.insert(rtp, 1, plugin.dir)
+ else
+ table.insert(rtp, plugin.dir)
+ end
+ end
+ end
+ end
+ return rtp
+end
+
+function M.find_root(modname)
+ local Cache = require("lazy.core.cache")
+ local modpath = Cache.find(modname, {
+ rtp = true,
+ paths = M.get_unloaded_rtp(modname),
+ patterns = { "", ".lua" },
+ })
+ if modpath then
+ local root = modpath:gsub("/init%.lua$", ""):gsub("%.lua$", "")
+ return root
+ end
+end
+
---@param modname string
---@param fn fun(modname:string, modpath:string)
function M.lsmod(modname, fn)
- local Cache = require("lazy.core.cache")
- local root = Cache.find_root(modname)
+ local root = M.find_root(modname)
if not root then
return
end
diff --git a/lua/lazy/docs.lua b/lua/lazy/docs.lua
index da3a166..bf42e98 100644
--- a/lua/lazy/docs.lua
+++ b/lua/lazy/docs.lua
@@ -131,12 +131,7 @@ function M.colors()
end
function M.update()
- local cache_config = M.extract("lua/lazy/core/cache.lua", "\nM%.config = ({.-\n})")
local config = M.extract("lua/lazy/core/config.lua", "\nM%.defaults = ({.-\n})")
- config = config:gsub(
- "\n%s*%-%-%-@type LazyCacheConfig.*cache = nil,",
- "\n" .. M.indent("cache = " .. cache_config .. ",", 4)
- )
config = config:gsub("%s*debug = false.\n", "\n")
M.save({
bootstrap = M.extract("lua/lazy/init.lua", "function M%.bootstrap%(%)\n(.-)\nend"),
diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua
index a0b073a..e81c4ec 100644
--- a/lua/lazy/init.lua
+++ b/lua/lazy/init.lua
@@ -34,13 +34,16 @@ function M.setup(spec, opts)
local start = vim.loop.hrtime()
-- load module cache before anything else
- require("lazy.core.cache").setup(opts)
+ if not (opts and opts.performance and opts.performance.cache and opts.performance.cache.enabled == false) then
+ require("lazy.core.cache").enable()
+ end
require("lazy.stats").track("LazyStart")
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
local Loader = require("lazy.core.loader")
+ table.insert(package.loaders, 3, Loader.loader)
Util.track({ plugin = "lazy.nvim" }) -- setup start
Util.track("module", vim.loop.hrtime() - start)
diff --git a/lua/lazy/manage/reloader.lua b/lua/lazy/manage/reloader.lua
index 7d30d3d..b6e1f1e 100644
--- a/lua/lazy/manage/reloader.lua
+++ b/lua/lazy/manage/reloader.lua
@@ -1,4 +1,3 @@
-local Cache = require("lazy.core.cache")
local Config = require("lazy.core.config")
local Util = require("lazy.util")
local Plugin = require("lazy.core.plugin")
@@ -6,12 +5,11 @@ local Loader = require("lazy.core.loader")
local M = {}
----@type table
+---@type table
M.files = {}
---@type vim.loop.Timer
M.timer = nil
-M.root = nil
function M.enable()
if M.timer then
@@ -19,7 +17,6 @@ function M.enable()
end
if #Config.spec.modules > 0 then
M.timer = vim.loop.new_timer()
- M.root = vim.fn.stdpath("config") .. "/lua"
M.check(true)
M.timer:start(2000, 2000, M.check)
end
@@ -32,6 +29,12 @@ function M.disable()
end
end
+---@param h1 vim.loop.Stat
+---@param h2 vim.loop.Stat
+function M.eq(h1, h2)
+ return h1 and h2 and h1.size == h2.size and h1.mtime.sec == h2.mtime.sec and h1.mtime.nsec == h2.mtime.nsec
+end
+
function M.check(start)
---@type table
local checked = {}
@@ -41,10 +44,10 @@ function M.check(start)
-- spec is a module
local function check(_, modpath)
checked[modpath] = true
- local hash = Cache.hash(modpath)
+ local hash = vim.loop.fs_stat(modpath)
if hash then
if M.files[modpath] then
- if not Cache.eq(M.files[modpath], hash) then
+ if not M.eq(M.files[modpath], hash) then
M.files[modpath] = hash
table.insert(changes, { file = modpath, what = "changed" })
end
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index e4f4529..6f6f857 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -672,33 +672,14 @@ function M:debug()
self:append("Cache.find()", "LazyH2"):nl()
self:props({
- { "total", Cache.stats.find.total, "Number" },
- { "time", self:ms(Cache.stats.find.time, 3), "Bold" },
- { "avg time", self:ms(Cache.stats.find.time / Cache.stats.find.total, 3), "Bold" },
- { "index", Cache.stats.find.index, "Number" },
- { "fs_stat", Cache.stats.find.stat, "Number" },
- { "not found", Cache.stats.find.not_found, "Number" },
+ { "total", Cache.stats.total, "Number" },
+ { "time", self:ms(Cache.stats.time, 3), "Bold" },
+ { "avg time", self:ms(Cache.stats.time / Cache.stats.total, 3), "Bold" },
+ { "index", Cache.stats.index, "Number" },
+ { "fs_stat", Cache.stats.stat, "Number" },
+ { "not found", Cache.stats.not_found, "Number" },
}, { indent = 2 })
self:nl()
-
- self:append("Cache.autoload()", "LazyH2"):nl()
- self:props({
- { "total", Cache.stats.autoload.total, "Number" },
- { "time", self:ms(Cache.stats.autoload.time, 3), "Bold" },
- { "avg time", self:ms(Cache.stats.autoload.time / Cache.stats.autoload.total, 3), "Bold" },
- }, { indent = 2 })
- self:nl()
-
- self:append("Cache", "LazyH2"):nl()
- local Cache = require("lazy.core.cache")
- Util.foreach(Cache.cache, function(modname, entry)
- local kb = math.floor(#entry.chunk / 10.24) / 100
- self:append("● ", "LazySpecial", { indent = 2 }):append(modname):append(" " .. kb .. "Kb", "Bold")
- if entry.modpath ~= modname then
- self:append(" " .. vim.fn.fnamemodify(entry.modpath, ":p:~:."), "LazyComment")
- end
- self:nl()
- end)
end
return M
diff --git a/tests/core/util_spec.lua b/tests/core/util_spec.lua
index 87102d3..86b9f06 100644
--- a/tests/core/util_spec.lua
+++ b/tests/core/util_spec.lua
@@ -51,10 +51,8 @@ describe("util", function()
local files = Helpers.fs_create(test.files)
-- test with empty cache
- Cache.cache = {}
- Cache.indexed = {}
- Cache.indexed_rtp = false
- local root = Cache.find_root(test.mod)
+ package.loaded["lazy.core.cache"] = nil
+ local root = Util.find_root(test.mod)
assert(root, "no root found for " .. test.mod .. " (test " .. t .. ")")
assert.same(Helpers.path(test.root), root)
local mods = {}
@@ -65,13 +63,8 @@ describe("util", function()
assert.same(expected, mods)
-- fill the cache
- Cache.cache = {}
- for i, file in ipairs(files) do
- Cache.cache[test.mods[i]] = { modpath = file }
- end
- Cache.indexed = {}
- Cache.indexed_rtp = false
- root = Cache.find_root(test.mod)
+ package.loaded["lazy.core.cache"] = nil
+ root = Util.find_root(test.mod)
assert(root, "no root found for " .. test.mod .. " (test " .. t .. ")")
assert.same(Helpers.path(test.root), root)
mods = {}
@@ -85,12 +78,12 @@ describe("util", function()
it("find the correct root with dels", function()
Cache.cache = {}
- Cache.indexed = {}
- Cache.indexed_rtp = false
+ Cache._topmods = {}
+ Cache.topmods_rtp = false
vim.opt.rtp:append(Helpers.path("old"))
Helpers.fs_create({ "old/lua/foobar/init.lua" })
Cache.cache["foobar"] = { modpath = Helpers.path("old/lua/foobar/init.lua") }
- local root = Cache.find_root("foobar")
+ local root = Util.find_root("foobar")
assert(root, "foobar root not found")
assert.same(Helpers.path("old/lua/foobar"), root)
@@ -98,24 +91,22 @@ describe("util", function()
assert(not vim.loop.fs_stat(Helpers.path("old/lua/foobar")), "old/lua/foobar should not exist")
-- vim.opt.rtp = rtp
- Cache.indexed = {}
- Cache.indexed_rtp = false
+ Cache._topmods = {}
vim.opt.rtp:append(Helpers.path("new"))
Helpers.fs_create({ "new/lua/foobar/init.lua" })
- root = Cache.find_root("foobar")
+ root = Util.find_root("foobar")
assert(root, "foobar root not found")
assert.same(Helpers.path("new/lua/foobar"), root)
end)
it("find the correct root with mod dels", function()
Cache.cache = {}
- Cache.indexed = {}
- Cache.indexed_rtp = false
+ Cache._topmods = {}
Cache.enabled = true
vim.opt.rtp:append(Helpers.path("old"))
Helpers.fs_create({ "old/lua/foobar/test.lua" })
Cache.cache["foobar.test"] = { modpath = Helpers.path("old/lua/foobar/test.lua") }
- local root = Cache.find_root("foobar")
+ local root = Util.find_root("foobar")
assert(root, "foobar root not found")
assert.same(Helpers.path("old/lua/foobar"), root)
assert(not Cache.cache["foobar"], "foobar should not be in cache")
@@ -124,11 +115,10 @@ describe("util", function()
Helpers.fs_rm("old")
-- vim.opt.rtp = rtp
- Cache.indexed = {}
- Cache.indexed_rtp = false
+ Cache._topmods = {}
vim.opt.rtp:append(Helpers.path("new"))
Helpers.fs_create({ "new/lua/foobar/test.lua" })
- root = Cache.find_root("foobar")
+ root = Util.find_root("foobar")
assert(root, "foobar root not found")
assert.same(Helpers.path("new/lua/foobar"), root)
end)
From 27fdb9b468e8c757dd02444738ae9bc2f3ec655e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 13 Feb 2023 11:02:38 +0000
Subject: [PATCH 166/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index ce6590e..d54890f 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 12
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 13
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
@@ -392,7 +392,7 @@ CONFIGURATION *lazy.nvim-configuration*
init = " ",
import = " ",
keys = " ",
- lazy = " ",
+ lazy = " ",
loaded = "",
not_loaded = "",
plugin = " ",
@@ -454,14 +454,6 @@ CONFIGURATION *lazy.nvim-configuration*
performance = {
cache = {
enabled = true,
- path = vim.fn.stdpath("cache") .. "/lazy/cache",
- -- Once one of the following events triggers, caching will be disabled.
- -- To cache all modules, set this to `{}`, but that is not recommended.
- -- The default is to disable on:
- -- VimEnter: not useful to cache anything else beyond startup
- -- BufReadPre: this will be triggered early when opening a file from the command line directly
- disable_events = { "UIEnter", "BufReadPre" },
- ttl = 3600 24 5, -- keep unused modules for up to 5 days
},
reset_packpath = true, -- reset the package path to improve startup time
rtp = {
From c778b7aa04c484e1536ba219e71f2fd0f05302aa Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Mon, 13 Feb 2023 12:07:52 +0100
Subject: [PATCH 167/992] chore(main): release 9.8.0 (#520)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 20 ++++++++++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a2ed41b..a8d9d82 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,25 @@
# Changelog
+## [9.8.0](https://github.com/folke/lazy.nvim/compare/v9.7.0...v9.8.0) (2023-02-13)
+
+
+### Features
+
+* **git:** `Plugin.submodules = false` will now skip fetching git submodules ([0d3f2c4](https://github.com/folke/lazy.nvim/commit/0d3f2c40421f4774c70f631d7b7023f57cba66cd))
+
+
+### Bug Fixes
+
+* **cmd:** fix Error when trigger on range defined command that doesn't support count ([#519](https://github.com/folke/lazy.nvim/issues/519)) ([a147110](https://github.com/folke/lazy.nvim/commit/a1471103902a9836d88732eeeeabd11d00a2cb3e))
+* **icons:** replace an obsolete Nerd icon ([#529](https://github.com/folke/lazy.nvim/issues/529)) ([bc978ca](https://github.com/folke/lazy.nvim/commit/bc978ca9be96b75330336a0427771addaa1ccd50))
+* **loader:** don't deactivate when not loaded ([c83d2ae](https://github.com/folke/lazy.nvim/commit/c83d2aeb27fce9cf9f14e779e77a85c63fc3d2c9))
+* **util:** executable checks for `Util.open` ([#528](https://github.com/folke/lazy.nvim/issues/528)) ([4917222](https://github.com/folke/lazy.nvim/commit/4917222c7e5c924bf7471b72a5e2d3e661530b40))
+
+
+### Performance Improvements
+
+* new file-based cache that ensures correct rtp order ([#532](https://github.com/folke/lazy.nvim/issues/532)) ([462633b](https://github.com/folke/lazy.nvim/commit/462633bae11255133f099163dda17180b3a6dc27))
+
## [9.7.0](https://github.com/folke/lazy.nvim/compare/v9.6.0...v9.7.0) (2023-02-08)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index bc8257b..14be512 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -147,7 +147,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.7.0" -- x-release-please-version
+M.version = "9.8.0" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From b1f7ae68a75401152eb23edbd5827b69761e9bc7 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 13 Feb 2023 17:22:00 +0100
Subject: [PATCH 168/992] perf: use modkey instead of modpath
---
lua/lazy/core/cache.lua | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 89d5a4a..0101ba0 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -113,8 +113,10 @@ end
function Cache.loader(modname)
modname = modname:gsub("/", ".")
local modpath, hash = Cache.find(modname)
+ local modpath, hash
+ modpath, hash = Cache.find(modname)
if modpath then
- return Cache.load(modpath, { hash = hash })
+ return Cache.load(modname, modpath, { hash = hash })
end
return "module " .. modname .. " not found"
end
@@ -126,7 +128,7 @@ end
---@private
function Cache.loadfile(filename, mode, env)
filename = Cache.normalize(filename)
- return Cache.load(filename, { mode = mode, env = env })
+ return Cache.load(filename, filename, { mode = mode, env = env })
end
---@param h1 CacheHash
@@ -137,10 +139,10 @@ function Cache.eq(h1, h2)
end
---@param modpath string
----@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table}
+---@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table, entry?: CacheEntry}
---@return function?, string? error_message
---@private
-function Cache.load(modpath, opts)
+function Cache.load(modkey, modpath, opts)
opts = opts or {}
local hash = opts.hash or uv.fs_stat(modpath)
if not hash then
@@ -150,10 +152,10 @@ function Cache.load(modpath, opts)
---@type function?, string?
local chunk, err
- local entry = Cache.read(modpath)
+ local entry = opts.entry or Cache.read(modkey)
if entry and Cache.eq(entry.hash, hash) then
-- found in cache and up to date
- chunk, err = loadstring(entry.chunk --[[@as string]], "@" .. entry.modpath)
+ chunk, err = load(entry.chunk --[[@as string]], "@" .. entry.modpath)
if not (err and err:find("cannot load incompatible bytecode", 1, true)) then
return chunk, err
end
@@ -163,7 +165,7 @@ function Cache.load(modpath, opts)
chunk, err = Cache._loadfile(entry.modpath)
if chunk then
entry.chunk = string.dump(chunk)
- Cache.write(modpath, entry)
+ Cache.write(modkey, entry)
end
return chunk, err
end
From 6351a2e8f32ff32652d13491de3aa21203d2a893 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 13 Feb 2023 17:24:15 +0100
Subject: [PATCH 169/992] refactor: Cache.stats -> Cache.stats.find
---
lua/lazy/core/cache.lua | 26 +++++++++++++-------------
lua/lazy/view/render.lua | 12 ++++++------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 0101ba0..adf1bfc 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -14,7 +14,7 @@ local M = {}
M.VERSION = 1
M.path = vim.fn.stdpath("cache") .. "/lazy/luac"
M.enabled = false
-M.stats = { total = 0, time = 0, index = 0, stat = 0, not_found = 0 }
+M.stats = { find = { total = 0, time = 0, index = 0, stat = 0, not_found = 0 } }
---@class ModuleCache
---@field _rtp string[]
@@ -176,7 +176,7 @@ end
function Cache.find(modname, opts)
opts = opts or {}
local start = uv.hrtime()
- M.stats.total = M.stats.total + 1
+ M.stats.find.total = M.stats.find.total + 1
modname = modname:gsub("/", ".")
local basename = modname:gsub("%.", "/")
local idx = modname:find(".", 1, true)
@@ -199,10 +199,10 @@ function Cache.find(modname, opts)
if M.lsmod(path)[topmod] then
for _, pattern in ipairs(patterns) do
local modpath = path .. pattern
- M.stats.stat = M.stats.stat + 1
+ M.stats.find.stat = M.stats.find.stat + 1
local hash = uv.fs_stat(modpath)
if hash then
- M.stats.time = M.stats.time + uv.hrtime() - start
+ M.stats.find.time = M.stats.find.time + uv.hrtime() - start
return modpath, hash
end
end
@@ -210,8 +210,8 @@ function Cache.find(modname, opts)
end
-- module not found
- M.stats.not_found = M.stats.not_found + 1
- M.stats.time = M.stats.time + uv.hrtime() - start
+ M.stats.find.not_found = M.stats.find.not_found + 1
+ M.stats.find.time = M.stats.find.time + uv.hrtime() - start
end
--- Resets the topmods cache for the path
@@ -250,7 +250,7 @@ end
---@return string[]
function M.lsmod(path)
if not Cache._topmods[path] then
- M.stats.index = M.stats.index + 1
+ M.stats.find.index = M.stats.find.index + 1
Cache._topmods[path] = {}
local handle = vim.loop.fs_scandir(path .. "/lua")
while handle do
@@ -288,12 +288,12 @@ function M.inspect()
return math.floor(nsec / 1e6 * 1000 + 0.5) / 1000 .. "ms"
end
local props = {
- { "total", M.stats.total, "Number" },
- { "time", ms(M.stats.time), "Bold" },
- { "avg time", ms(M.stats.time / M.stats.total), "Bold" },
- { "index", M.stats.index, "Number" },
- { "fs_stat", M.stats.stat, "Number" },
- { "not found", M.stats.not_found, "Number" },
+ { "total", M.stats.find.total, "Number" },
+ { "time", ms(M.stats.find.time), "Bold" },
+ { "avg time", ms(M.stats.find.time / M.stats.find.total), "Bold" },
+ { "index", M.stats.find.index, "Number" },
+ { "fs_stat", M.stats.find.stat, "Number" },
+ { "not found", M.stats.find.not_found, "Number" },
}
local chunks = {} ---@type string[][]
for _, prop in ipairs(props) do
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index 6f6f857..ec5570e 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -672,12 +672,12 @@ function M:debug()
self:append("Cache.find()", "LazyH2"):nl()
self:props({
- { "total", Cache.stats.total, "Number" },
- { "time", self:ms(Cache.stats.time, 3), "Bold" },
- { "avg time", self:ms(Cache.stats.time / Cache.stats.total, 3), "Bold" },
- { "index", Cache.stats.index, "Number" },
- { "fs_stat", Cache.stats.stat, "Number" },
- { "not found", Cache.stats.not_found, "Number" },
+ { "total", Cache.stats.find.total, "Number" },
+ { "time", self:ms(Cache.stats.find.time, 3), "Bold" },
+ { "avg time", self:ms(Cache.stats.find.time / Cache.stats.find.total, 3), "Bold" },
+ { "index", Cache.stats.find.index, "Number" },
+ { "fs_stat", Cache.stats.find.stat, "Number" },
+ { "not found", Cache.stats.find.not_found, "Number" },
}, { indent = 2 })
self:nl()
end
From 17a3c3acea400679027e675cc19b738e842a5ea0 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 14 Feb 2023 11:00:56 +0100
Subject: [PATCH 170/992] perf: more cache optims
---
.neoconf.json | 2 +-
lua/lazy/core/cache.lua | 241 +++++++++++++++++++++++++++------------
lua/lazy/core/loader.lua | 41 ++++---
lua/lazy/init.lua | 13 ++-
lua/lazy/view/render.lua | 25 ++--
5 files changed, 224 insertions(+), 98 deletions(-)
diff --git a/.neoconf.json b/.neoconf.json
index 67828bb..f0c23f8 100644
--- a/.neoconf.json
+++ b/.neoconf.json
@@ -7,7 +7,7 @@
}
},
"lspconfig": {
- "sumneko_lua": {
+ "lua_ls": {
"Lua.runtime.version": "LuaJIT",
"Lua.workspace.checkThirdParty": false
}
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index adf1bfc..3b3d824 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -4,33 +4,44 @@ local uv = vim.loop
local M = {}
---@alias CacheHash {mtime: {sec:number, nsec:number}, size:number}
----@alias CacheEntry {hash:CacheHash, modpath:string, chunk:string}
+---@alias CacheEntry {hash:CacheHash, chunk:string}
---@class CacheFindOpts
---@field rtp? boolean Search for modname in the runtime path (defaults to `true`)
---@field patterns? string[] Paterns to use (defaults to `{"/init.lua", ".lua"}`)
---@field paths? string[] Extra paths to search for modname
-M.VERSION = 1
+M.VERSION = 2
M.path = vim.fn.stdpath("cache") .. "/lazy/luac"
M.enabled = false
-M.stats = { find = { total = 0, time = 0, index = 0, stat = 0, not_found = 0 } }
+M.stats = {
+ find = { total = 0, time = 0, not_found = 0 },
+}
---@class ModuleCache
---@field _rtp string[]
+---@field _rtp_pure string[]
---@field _rtp_key string
local Cache = {
---@type table>
+ _indexed = {},
+ ---@type table
_topmods = {},
_loadfile = loadfile,
}
+function M.track(stat, start)
+ M.stats[stat] = M.stats[stat] or { total = 0, time = 0 }
+ M.stats[stat].total = M.stats[stat].total + 1
+ M.stats[stat].time = M.stats[stat].time + uv.hrtime() - start
+end
+
-- slightly faster/different version than vim.fs.normalize
-- we also need to have it here, since the cache will load vim.fs
---@private
function Cache.normalize(path)
if path:sub(1, 1) == "~" then
- local home = vim.loop.os_homedir()
+ local home = vim.loop.os_homedir() or "~"
if home:sub(-1) == "\\" or home:sub(-1) == "/" then
home = home:sub(1, -2)
end
@@ -42,28 +53,34 @@ end
---@private
function Cache.get_rtp()
+ local start = uv.hrtime()
if vim.in_fast_event() then
- return Cache._rtp or {}
+ M.track("get_rtp", start)
+ return (Cache._rtp or {}), false
end
+ local updated = false
local key = vim.go.rtp
if key ~= Cache._rtp_key then
Cache._rtp = {}
for _, path in ipairs(vim.api.nvim_get_runtime_file("", true)) do
path = Cache.normalize(path)
-- skip after directories
- if path:sub(-6, -1) ~= "/after" then
+ if path:sub(-6, -1) ~= "/after" and not (Cache._indexed[path] and vim.tbl_isempty(Cache._indexed[path])) then
Cache._rtp[#Cache._rtp + 1] = path
end
end
+ updated = true
Cache._rtp_key = key
end
- return Cache._rtp
+ M.track("get_rtp", start)
+ return Cache._rtp, updated
end
---@param name string can be a module name, or a file name
---@private
function Cache.cache_file(name)
- return M.path .. "/" .. name:gsub("[/\\:]", "%%") .. "c"
+ local ret = M.path .. "/" .. name:gsub("[/\\:]", "%%")
+ return ret:sub(-4) == ".lua" and (ret .. "c") or (ret .. ".luac")
end
---@param entry CacheEntry
@@ -76,10 +93,8 @@ function Cache.write(name, entry)
entry.hash.size,
entry.hash.mtime.sec,
entry.hash.mtime.nsec,
- #entry.modpath,
}
- uv.fs_write(f, ffi.string(ffi.new("const uint32_t[5]", header), 20))
- uv.fs_write(f, entry.modpath)
+ uv.fs_write(f, ffi.string(ffi.new("const uint32_t[4]", header), 16))
uv.fs_write(f, entry.chunk)
uv.fs_close(f)
end
@@ -87,6 +102,7 @@ end
---@return CacheEntry?
---@private
function Cache.read(name)
+ local start = uv.hrtime()
local cname = Cache.cache_file(name)
local f = uv.fs_open(cname, "r", 438)
if f then
@@ -95,29 +111,52 @@ function Cache.read(name)
uv.fs_close(f)
---@type integer[]|{[0]:integer}
- local header = ffi.cast("uint32_t*", ffi.new("const char[20]", data:sub(1, 20)))
+ local header = ffi.cast("uint32_t*", ffi.new("const char[16]", data:sub(1, 16)))
if header[0] ~= M.VERSION then
return
end
- local modpath = data:sub(21, 20 + header[4])
+ M.track("read", start)
return {
hash = { size = header[1], mtime = { sec = header[2], nsec = header[3] } },
- chunk = data:sub(20 + header[4] + 1),
- modpath = modpath,
+ chunk = data:sub(16 + 1),
}
end
+ M.track("read", start)
end
---@param modname string
---@private
function Cache.loader(modname)
- modname = modname:gsub("/", ".")
+ local start = uv.hrtime()
local modpath, hash = Cache.find(modname)
- local modpath, hash
- modpath, hash = Cache.find(modname)
+ ---@type function?, string?
+ local chunk, err
if modpath then
- return Cache.load(modname, modpath, { hash = hash })
+ chunk, err = M.load(modpath, { hash = hash })
end
+ M.track("loader", start)
+ return chunk or err or "module " .. modname .. " not found"
+end
+
+---@param modname string
+---@private
+function Cache.loader_lib(modname)
+ local start = uv.hrtime()
+ local modpath = Cache.find(modname, { patterns = jit.os:find("Windows") and { ".dll" } or { ".so" } })
+ ---@type function?, string?
+ if modpath then
+ -- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is
+ -- a) strip prefix up to and including the first dash, if any
+ -- b) replace all dots by underscores
+ -- c) prepend "luaopen_"
+ -- So "foo-bar.baz" should result in "luaopen_bar_baz"
+ local dash = modname:find("-", 1, true)
+ local funcname = dash and modname:sub(dash + 1) or modname
+ local chunk, err = package.loadlib(modpath, "luaopen_" .. funcname:gsub("%.", "_"))
+ M.track("loader_lib", start)
+ return chunk or err
+ end
+ M.track("loader_lib", start)
return "module " .. modname .. " not found"
end
@@ -127,8 +166,11 @@ end
---@return function?, string? error_message
---@private
function Cache.loadfile(filename, mode, env)
+ local start = uv.hrtime()
filename = Cache.normalize(filename)
- return Cache.load(filename, filename, { mode = mode, env = env })
+ local chunk, err = M.load(filename, { mode = mode, env = env })
+ M.track("loadfile", start)
+ return chunk, err
end
---@param h1 CacheHash
@@ -139,44 +181,52 @@ function Cache.eq(h1, h2)
end
---@param modpath string
----@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table, entry?: CacheEntry}
+---@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table}
---@return function?, string? error_message
---@private
-function Cache.load(modkey, modpath, opts)
+function M.load(modpath, opts)
+ local start = uv.hrtime()
+
opts = opts or {}
local hash = opts.hash or uv.fs_stat(modpath)
- if not hash then
- -- trigger correct error
- return Cache._loadfile(modpath)
- end
-
---@type function?, string?
local chunk, err
- local entry = opts.entry or Cache.read(modkey)
+
+ if not hash then
+ -- trigger correct error
+ chunk, err = Cache._loadfile(modpath, opts.mode, opts.env)
+ M.track("load", start)
+ return chunk, err
+ end
+
+ local entry = Cache.read(modpath)
if entry and Cache.eq(entry.hash, hash) then
-- found in cache and up to date
- chunk, err = load(entry.chunk --[[@as string]], "@" .. entry.modpath)
+ -- selene: allow(incorrect_standard_library_use)
+ chunk, err = load(entry.chunk --[[@as string]], "@" .. modpath, opts.mode, opts.env)
if not (err and err:find("cannot load incompatible bytecode", 1, true)) then
+ M.track("load", start)
return chunk, err
end
end
entry = { hash = hash, modpath = modpath }
- chunk, err = Cache._loadfile(entry.modpath)
+ chunk, err = Cache._loadfile(modpath, opts.mode, opts.env)
if chunk then
entry.chunk = string.dump(chunk)
- Cache.write(modkey, entry)
+ Cache.write(modpath, entry)
end
+ M.track("load", start)
return chunk, err
end
---@param modname string
---@param opts? CacheFindOpts
----@return string? modpath, CacheHash? hash
+---@return string? modpath, CacheHash? hash, CacheEntry? entry
function Cache.find(modname, opts)
- opts = opts or {}
local start = uv.hrtime()
- M.stats.find.total = M.stats.find.total + 1
+ opts = opts or {}
+
modname = modname:gsub("/", ".")
local basename = modname:gsub("%.", "/")
local idx = modname:find(".", 1, true)
@@ -184,40 +234,54 @@ function Cache.find(modname, opts)
-- OPTIM: search for a directory first when topmod == modname
local patterns = opts.patterns or (topmod == modname and { "/init.lua", ".lua" } or { ".lua", "/init.lua" })
- local rtp = opts.rtp ~= false and Cache.get_rtp() or {}
- if opts.paths then
- rtp = vim.deepcopy(rtp)
- for _, dir in ipairs(opts.paths) do
- rtp[#rtp + 1] = Cache.normalize(dir)
- end
- end
for p, pattern in ipairs(patterns) do
patterns[p] = "/lua/" .. basename .. pattern
end
- for _, path in ipairs(rtp) do
- if M.lsmod(path)[topmod] then
- for _, pattern in ipairs(patterns) do
- local modpath = path .. pattern
- M.stats.find.stat = M.stats.find.stat + 1
- local hash = uv.fs_stat(modpath)
- if hash then
- M.stats.find.time = M.stats.find.time + uv.hrtime() - start
- return modpath, hash
+ ---@param paths string[]
+ local function _find(paths)
+ for _, path in ipairs(paths) do
+ if M.lsmod(path)[topmod] then
+ for _, pattern in ipairs(patterns) do
+ local modpath = path .. pattern
+ M.stats.find.stat = (M.stats.find.stat or 0) + 1
+ local hash = uv.fs_stat(modpath)
+ if hash then
+ return modpath, hash
+ end
end
end
end
end
+ ---@type string, CacheHash
+ local modpath, hash
+
+ if opts.rtp ~= false then
+ modpath, hash = _find(Cache._rtp or {})
+ if not modpath then
+ local rtp, updated = Cache.get_rtp()
+ if updated then
+ modpath, hash = _find(rtp)
+ end
+ end
+ end
+ if (not modpath) and opts.paths then
+ modpath, hash = _find(opts.paths)
+ end
+
+ M.track("find", start)
+ if modpath then
+ return modpath, hash
+ end
-- module not found
M.stats.find.not_found = M.stats.find.not_found + 1
- M.stats.find.time = M.stats.find.time + uv.hrtime() - start
end
--- Resets the topmods cache for the path
---@param path string
function M.reset(path)
- Cache._topmods[Cache.normalize(path)] = nil
+ Cache._indexed[Cache.normalize(path)] = nil
end
function M.enable()
@@ -228,7 +292,17 @@ function M.enable()
vim.fn.mkdir(vim.fn.fnamemodify(M.path, ":p"), "p")
-- selene: allow(global_usage)
_G.loadfile = Cache.loadfile
+ -- add lua loader
table.insert(package.loaders, 2, Cache.loader)
+ -- add libs loader
+ table.insert(package.loaders, 3, Cache.loader_lib)
+ -- remove Neovim loader
+ for l, loader in ipairs(package.loaders) do
+ if loader == vim._load_package then
+ table.remove(package.loaders, l)
+ break
+ end
+ end
end
function M.disable()
@@ -240,18 +314,19 @@ function M.disable()
_G.loadfile = Cache._loadfile
---@diagnostic disable-next-line: no-unknown
for l, loader in ipairs(package.loaders) do
- if loader == Cache.loader then
+ if loader == Cache.loader or loader == Cache.loader_lib then
table.remove(package.loaders, l)
end
end
+ table.insert(package.loaders, 2, vim._load_package)
end
-- Return the top-level `/lua/*` modules for this path
---@return string[]
function M.lsmod(path)
- if not Cache._topmods[path] then
- M.stats.find.index = M.stats.find.index + 1
- Cache._topmods[path] = {}
+ if not Cache._indexed[path] then
+ local start = uv.hrtime()
+ Cache._indexed[path] = {}
local handle = vim.loop.fs_scandir(path .. "/lua")
while handle do
local name, t = vim.loop.fs_scandir_next(handle)
@@ -259,7 +334,7 @@ function M.lsmod(path)
break
end
-- HACK: type is not always returned due to a bug in luv
- t = t or vim.loop.fs_stat(path .. "/" .. name).type
+ t = t or uv.fs_stat(path .. "/" .. name).type
---@type string
local topname
if name:sub(-4) == ".lua" then
@@ -268,11 +343,16 @@ function M.lsmod(path)
topname = name
end
if topname then
- Cache._topmods[path][topname] = true
+ Cache._indexed[path][topname] = true
+ Cache._topmods[topname] = Cache._topmods[topname] or {}
+ if not vim.tbl_contains(Cache._topmods[topname], path) then
+ table.insert(Cache._topmods[topname], path)
+ end
end
end
+ M.track("lsmod", start)
end
- return Cache._topmods[path]
+ return Cache._indexed[path]
end
---@param modname string
@@ -283,22 +363,43 @@ function M.find(modname, opts)
return modpath
end
+function M.profile_loaders()
+ for l, loader in pairs(package.loaders) do
+ local loc = debug.getinfo(loader, "Sn").source:sub(2)
+ package.loaders[l] = function(modname)
+ local start = vim.loop.hrtime()
+ local ret = loader(modname)
+ M.track("loader " .. l .. ": " .. loc, start)
+ M.track("loader_all", start)
+ return ret
+ end
+ end
+end
+
function M.inspect()
local function ms(nsec)
return math.floor(nsec / 1e6 * 1000 + 0.5) / 1000 .. "ms"
end
- local props = {
- { "total", M.stats.find.total, "Number" },
- { "time", ms(M.stats.find.time), "Bold" },
- { "avg time", ms(M.stats.find.time / M.stats.find.total), "Bold" },
- { "index", M.stats.find.index, "Number" },
- { "fs_stat", M.stats.find.stat, "Number" },
- { "not found", M.stats.find.not_found, "Number" },
- }
local chunks = {} ---@type string[][]
- for _, prop in ipairs(props) do
- chunks[#chunks + 1] = { "* " .. prop[1] .. ": " }
- chunks[#chunks + 1] = { tostring(prop[2]) .. "\n", prop[3] }
+ ---@type string[]
+ local stats = vim.tbl_keys(M.stats)
+ table.sort(stats)
+ for _, stat in ipairs(stats) do
+ vim.list_extend(chunks, {
+ { "\n" .. stat .. "\n", "Title" },
+ { "* total: " },
+ { tostring(M.stats[stat].total) .. "\n", "Number" },
+ { "* time: " },
+ { ms(M.stats[stat].time) .. "\n", "Bold" },
+ { "* avg time: " },
+ { ms(M.stats[stat].time / M.stats[stat].total) .. "\n", "Bold" },
+ })
+ for k, v in pairs(M.stats[stat]) do
+ if not vim.tbl_contains({ "time", "total" }, k) then
+ chunks[#chunks + 1] = { "* " .. k .. ":" .. string.rep(" ", 9 - #k) }
+ chunks[#chunks + 1] = { tostring(v) .. "\n", "Number" }
+ end
+ end
end
vim.api.nvim_echo(chunks, true, {})
end
diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua
index 0f1b977..833b432 100644
--- a/lua/lazy/core/loader.lua
+++ b/lua/lazy/core/loader.lua
@@ -4,6 +4,7 @@ local Handler = require("lazy.core.handler")
local Cache = require("lazy.core.cache")
local Plugin = require("lazy.core.plugin")
+---@class LazyCoreLoader
local M = {}
local DEFAULT_PRIORITY = 50
@@ -450,27 +451,35 @@ function M.colorscheme(name)
end
end
+function M.auto_load(modname, modpath)
+ local plugin = Plugin.find(modpath)
+ if plugin and modpath:find(plugin.dir, 1, true) == 1 then
+ -- don't load if we're loading specs or if the plugin is already loaded
+ if not (Plugin.loading or plugin._.loaded) then
+ if plugin.module == false then
+ error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
+ end
+ M.load(plugin, { require = modname })
+ end
+ return true
+ end
+ return false
+end
+
---@param modname string
function M.loader(modname)
- local modpath = Cache.find(modname, { rtp = false, paths = Util.get_unloaded_rtp(modname) })
+ local paths = Util.get_unloaded_rtp(modname)
+ local modpath, hash = Cache._Cache.find(modname, { rtp = false, paths = paths })
+ -- print(modname .. " " .. paths[1])
if modpath then
- local plugin = Plugin.find(modpath)
- if plugin and modpath:find(plugin.dir, 1, true) == 1 then
- -- don't load if we're loading specs or if the plugin is already loaded
- if not (Plugin.loading or plugin._.loaded) then
- if plugin.module == false then
- error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
- end
- M.load(plugin, { require = modname })
+ M.auto_load(modname, modpath)
+ local mod = package.loaded[modname]
+ if type(mod) == "table" then
+ return function()
+ return mod
end
- local mod = package.loaded[modname]
- if type(mod) == "table" then
- return function()
- return mod
- end
- end
- return loadfile(modpath)
end
+ return Cache.load(modpath, { hash = hash })
end
end
diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua
index e81c4ec..cb6b732 100644
--- a/lua/lazy/init.lua
+++ b/lua/lazy/init.lua
@@ -34,7 +34,13 @@ function M.setup(spec, opts)
local start = vim.loop.hrtime()
-- load module cache before anything else
- if not (opts and opts.performance and opts.performance.cache and opts.performance.cache.enabled == false) then
+ local enable_cache = not (
+ opts
+ and opts.performance
+ and opts.performance.cache
+ and opts.performance.cache.enabled == false
+ )
+ if enable_cache then
require("lazy.core.cache").enable()
end
@@ -43,8 +49,13 @@ function M.setup(spec, opts)
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
local Loader = require("lazy.core.loader")
+
table.insert(package.loaders, 3, Loader.loader)
+ if vim.g.profile_loaders then
+ require("lazy.core.cache").profile_loaders()
+ end
+
Util.track({ plugin = "lazy.nvim" }) -- setup start
Util.track("module", vim.loop.hrtime() - start)
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index ec5570e..56ac095 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -670,16 +670,21 @@ function M:debug()
end)
self:nl()
- self:append("Cache.find()", "LazyH2"):nl()
- self:props({
- { "total", Cache.stats.find.total, "Number" },
- { "time", self:ms(Cache.stats.find.time, 3), "Bold" },
- { "avg time", self:ms(Cache.stats.find.time / Cache.stats.find.total, 3), "Bold" },
- { "index", Cache.stats.find.index, "Number" },
- { "fs_stat", Cache.stats.find.stat, "Number" },
- { "not found", Cache.stats.find.not_found, "Number" },
- }, { indent = 2 })
- self:nl()
+ Util.foreach(Cache.stats, function(name, stats)
+ self:append(name, "LazyH2"):nl()
+ local props = {
+ { "total", stats.total or 0, "Number" },
+ { "time", self:ms(stats.time or 0, 3), "Bold" },
+ { "avg time", self:ms((stats.time or 0) / (stats.total or 0), 3), "Bold" },
+ }
+ for k, v in pairs(stats) do
+ if k ~= "total" and k ~= "time" then
+ props[#props + 1] = { k, v, "Number" }
+ end
+ end
+ self:props(props, { indent = 2 })
+ self:nl()
+ end)
end
return M
From 8aa90c34233f7de420b326de361137a571827d8c Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Tue, 14 Feb 2023 10:01:58 +0000
Subject: [PATCH 171/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index d54890f..5478a10 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 13
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 14
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 6a18404b7d1c05f0d1f35f7b78bd5c282dff7a89 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 14 Feb 2023 12:19:49 +0100
Subject: [PATCH 172/992] fix(keys): fixed keys types. rhs can be `false`
---
lua/lazy/core/handler/keys.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index 8285240..b1fbc6d 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -3,7 +3,7 @@ local Loader = require("lazy.core.loader")
---@class LazyKeys
---@field [1] string lhs
----@field [2]? string|fun() rhs
+---@field [2]? string|fun()|false rhs
---@field desc? string
---@field mode? string|string[]
---@field noremap? boolean
From c249ea376bcd3e5d121b79eac595837b7d0c73a4 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 14 Feb 2023 22:05:14 +0100
Subject: [PATCH 173/992] chore(main): release 9.8.1 (#538)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 13 +++++++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a8d9d82..6a8fd45 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## [9.8.1](https://github.com/folke/lazy.nvim/compare/v9.8.0...v9.8.1) (2023-02-14)
+
+
+### Bug Fixes
+
+* **keys:** fixed keys types. rhs can be `false` ([6a18404](https://github.com/folke/lazy.nvim/commit/6a18404b7d1c05f0d1f35f7b78bd5c282dff7a89))
+
+
+### Performance Improvements
+
+* more cache optims ([17a3c3a](https://github.com/folke/lazy.nvim/commit/17a3c3acea400679027e675cc19b738e842a5ea0))
+* use modkey instead of modpath ([b1f7ae6](https://github.com/folke/lazy.nvim/commit/b1f7ae68a75401152eb23edbd5827b69761e9bc7))
+
## [9.8.0](https://github.com/folke/lazy.nvim/compare/v9.7.0...v9.8.0) (2023-02-13)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 14be512..4c8c071 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -147,7 +147,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.8.0" -- x-release-please-version
+M.version = "9.8.1" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 78264fb9350814c32ca9442ff3113e15a8218dad Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 15 Feb 2023 17:07:57 +0100
Subject: [PATCH 174/992] style: added proper types to process
---
lua/lazy/manage/process.lua | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/lua/lazy/manage/process.lua b/lua/lazy/manage/process.lua
index fd5f898..530aeaa 100644
--- a/lua/lazy/manage/process.lua
+++ b/lua/lazy/manage/process.lua
@@ -2,7 +2,7 @@ local Config = require("lazy.core.config")
local M = {}
----@type table
+---@type table
M.running = {}
M.signals = {
@@ -57,28 +57,31 @@ function M.spawn(cmd, opts)
opts = opts or {}
opts.timeout = opts.timeout or (Config.options.git and Config.options.git.timeout * 1000)
+ ---@type table
local env = vim.tbl_extend("force", {
GIT_SSH_COMMAND = "ssh -oBatchMode=yes",
}, uv.os_environ(), opts.env or {})
env.GIT_DIR = nil
env.GIT_TERMINAL_PROMPT = "0"
+ ---@type string[]
local env_flat = {}
for k, v in pairs(env) do
env_flat[#env_flat + 1] = k .. "=" .. v
end
- local stdout = uv.new_pipe()
- local stderr = uv.new_pipe()
+ local stdout = assert(uv.new_pipe())
+ local stderr = assert(uv.new_pipe())
local output = ""
- ---@type vim.loop.Process
+ ---@type uv.uv_process_t
local handle = nil
+ ---@type uv.uv_timer_t
local timeout
local killed = false
if opts.timeout then
- timeout = uv.new_timer()
+ timeout = assert(uv.new_timer())
timeout:start(opts.timeout, 0, function()
if M.kill(handle) then
killed = true
@@ -100,7 +103,7 @@ function M.spawn(cmd, opts)
handle:close()
stdout:close()
stderr:close()
- local check = uv.new_check()
+ local check = assert(uv.new_check())
check:start(function()
if not stdout:is_closing() or not stderr:is_closing() then
return
From 9ca3222061fcc07a7ac5f685d80b49944b347a03 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 15 Feb 2023 17:08:36 +0100
Subject: [PATCH 175/992] fix(cache): lsmod now also supports lua libs. Fixes
#544
---
lua/lazy/core/cache.lua | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 3b3d824..12515ec 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -129,13 +129,13 @@ end
function Cache.loader(modname)
local start = uv.hrtime()
local modpath, hash = Cache.find(modname)
- ---@type function?, string?
- local chunk, err
if modpath then
- chunk, err = M.load(modpath, { hash = hash })
+ local chunk, err = M.load(modpath, { hash = hash })
+ M.track("loader", start)
+ return chunk or error(err)
end
M.track("loader", start)
- return chunk or err or "module " .. modname .. " not found"
+ return "\nlazy_loader: module " .. modname .. " not found"
end
---@param modname string
@@ -154,10 +154,10 @@ function Cache.loader_lib(modname)
local funcname = dash and modname:sub(dash + 1) or modname
local chunk, err = package.loadlib(modpath, "luaopen_" .. funcname:gsub("%.", "_"))
M.track("loader_lib", start)
- return chunk or err
+ return chunk or error(err)
end
M.track("loader_lib", start)
- return "module " .. modname .. " not found"
+ return "\nlazy_loader_lib: module " .. modname .. " not found"
end
---@param filename? string
@@ -337,8 +337,11 @@ function M.lsmod(path)
t = t or uv.fs_stat(path .. "/" .. name).type
---@type string
local topname
- if name:sub(-4) == ".lua" then
+ local ext = name:sub(-4)
+ if ext == ".lua" or ext == ".dll" then
topname = name:sub(1, -5)
+ elseif name:sub(-3) == ".so" then
+ topname = name:sub(1, -4)
elseif t == "link" or t == "directory" then
topname = name
end
From 8f752bb28836829387a21a8afb7ad41f0c93bda7 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 15 Feb 2023 16:09:23 +0000
Subject: [PATCH 176/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 5478a10..388f622 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 14
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 15
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 4a0857cc232ddb31f64d1e5f42fd19e09a490f83 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Wed, 15 Feb 2023 17:14:00 +0100
Subject: [PATCH 177/992] chore(main): release 9.8.2 (#548)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 7 +++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6a8fd45..d568692 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## [9.8.2](https://github.com/folke/lazy.nvim/compare/v9.8.1...v9.8.2) (2023-02-15)
+
+
+### Bug Fixes
+
+* **cache:** lsmod now also supports lua libs. Fixes [#544](https://github.com/folke/lazy.nvim/issues/544) ([9ca3222](https://github.com/folke/lazy.nvim/commit/9ca3222061fcc07a7ac5f685d80b49944b347a03))
+
## [9.8.1](https://github.com/folke/lazy.nvim/compare/v9.8.0...v9.8.1) (2023-02-14)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 4c8c071..befd3bc 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -147,7 +147,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.8.1" -- x-release-please-version
+M.version = "9.8.2" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From e916f41df26e33b01f1b3ebe28881090da3a7281 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Wed, 15 Feb 2023 18:19:57 +0100
Subject: [PATCH 178/992] fix(cache): hack to work around plugins trying to
load relatve modules. Fixes #543
---
lua/lazy/core/cache.lua | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 12515ec..8a02711 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -230,6 +230,14 @@ function Cache.find(modname, opts)
modname = modname:gsub("/", ".")
local basename = modname:gsub("%.", "/")
local idx = modname:find(".", 1, true)
+
+ -- HACK: some plugins try to load invalid relative paths (see #543)
+ if idx == 1 then
+ modname = modname:gsub("^%.+", "")
+ basename = modname:gsub("%.", "/")
+ idx = modname:find(".", 1, true)
+ end
+
local topmod = idx and modname:sub(1, idx - 1) or modname
-- OPTIM: search for a directory first when topmod == modname
From 6771c7e23c3ecdb50a9510c4cd5e1e0d2db9e5ca Mon Sep 17 00:00:00 2001
From: vanppo
Date: Thu, 16 Feb 2023 19:33:53 +0800
Subject: [PATCH 179/992] fix(ui): disable folding of floating window (#550)
---
lua/lazy/view/float.lua | 1 +
1 file changed, 1 insertion(+)
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index 2a2cc5f..f0e719a 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -107,6 +107,7 @@ function M:mount()
local function opts()
vim.bo[self.buf].bufhidden = "wipe"
vim.wo[self.win].conceallevel = 3
+ vim.wo[self.win].foldenable = false
vim.wo[self.win].spell = false
vim.wo[self.win].wrap = true
vim.wo[self.win].winhighlight = "Normal:LazyNormal"
From 258ee6b30dd842bdd486da1ea8873644ed536a73 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 16 Feb 2023 11:34:49 +0000
Subject: [PATCH 180/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 388f622..07f69c8 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 15
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 16
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 8186cc5db31bd5968b5be838a30c4cf1465cb3f9 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Thu, 16 Feb 2023 13:29:23 +0100
Subject: [PATCH 181/992] chore(main): release 9.8.3 (#549)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 8 ++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d568692..0ac92d0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## [9.8.3](https://github.com/folke/lazy.nvim/compare/v9.8.2...v9.8.3) (2023-02-16)
+
+
+### Bug Fixes
+
+* **cache:** hack to work around plugins trying to load relatve modules. Fixes [#543](https://github.com/folke/lazy.nvim/issues/543) ([e916f41](https://github.com/folke/lazy.nvim/commit/e916f41df26e33b01f1b3ebe28881090da3a7281))
+* **ui:** disable folding of floating window ([#550](https://github.com/folke/lazy.nvim/issues/550)) ([6771c7e](https://github.com/folke/lazy.nvim/commit/6771c7e23c3ecdb50a9510c4cd5e1e0d2db9e5ca))
+
## [9.8.2](https://github.com/folke/lazy.nvim/compare/v9.8.1...v9.8.2) (2023-02-15)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index befd3bc..f1e5f3f 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -147,7 +147,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.8.2" -- x-release-please-version
+M.version = "9.8.3" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 5cfe1560c551720bdc125e68431bacb836eb28d3 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 17 Feb 2023 13:41:16 +0100
Subject: [PATCH 182/992] fix(ui): return abort key instead of ``
---
lua/lazy/view/init.lua | 2 +-
lua/lazy/view/render.lua | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua
index efdb75e..b661d5a 100644
--- a/lua/lazy/view/init.lua
+++ b/lua/lazy/view/init.lua
@@ -77,7 +77,7 @@ function M.create()
vim.keymap.set("n", ViewConfig.keys.abort, function()
require("lazy.manage.process").abort()
- return ""
+ return ViewConfig.keys.abort
end, { silent = true, buffer = self.buf, expr = true })
-- plugin details
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index 56ac095..6cf424c 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -160,7 +160,7 @@ end
function M:help()
self:append("Help", "LazyH2"):nl():nl()
- self:append("Use "):append("", "LazySpecial"):append(" to abort all running tasks."):nl():nl()
+ self:append("Use "):append(ViewConfig.keys.abort, "LazySpecial"):append(" to abort all running tasks."):nl():nl()
self:append("You can press "):append("", "LazySpecial"):append(" on a plugin to show its details."):nl():nl()
From e5ba4434164f8ae9f88d5150018f229e3d0aa9a7 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Fri, 17 Feb 2023 12:42:16 +0000
Subject: [PATCH 183/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 07f69c8..5753584 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 16
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 17
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From ff76e58961509038e3e0365c47580e595977a3a2 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 17 Feb 2023 13:58:16 +0100
Subject: [PATCH 184/992] fix(spec): make sure imported specs are sorted
alphabetically
---
lua/lazy/core/plugin.lua | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index b79cc6b..edd8ff0 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -254,7 +254,15 @@ function Spec:import(spec)
self.modules[#self.modules + 1] = spec.import
local imported = 0
+
+ ---@type string[]
+ local modnames = {}
Util.lsmod(spec.import, function(modname)
+ modnames[#modnames + 1] = modname
+ end)
+ table.sort(modnames)
+
+ for _, modname in ipairs(modnames) do
imported = imported + 1
Util.track({ import = modname })
self.importing = modname
@@ -273,7 +281,7 @@ function Spec:import(spec)
Util.track()
end,
})
- end)
+ end
if imported == 0 then
self:error("No specs found for module " .. spec.import)
end
From f2cc9ef6acc7367c001b7507c82cab3ab7c29cae Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Fri, 17 Feb 2023 17:06:19 +0100
Subject: [PATCH 185/992] chore(main): release 9.8.4 (#557)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 8 ++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0ac92d0..5ed8af5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## [9.8.4](https://github.com/folke/lazy.nvim/compare/v9.8.3...v9.8.4) (2023-02-17)
+
+
+### Bug Fixes
+
+* **spec:** make sure imported specs are sorted alphabetically ([ff76e58](https://github.com/folke/lazy.nvim/commit/ff76e58961509038e3e0365c47580e595977a3a2))
+* **ui:** return abort key instead of `<c-c>` ([5cfe156](https://github.com/folke/lazy.nvim/commit/5cfe1560c551720bdc125e68431bacb836eb28d3))
+
## [9.8.3](https://github.com/folke/lazy.nvim/compare/v9.8.2...v9.8.3) (2023-02-16)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index f1e5f3f..310e11c 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -147,7 +147,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.8.3" -- x-release-please-version
+M.version = "9.8.4" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 7339145a223dab7e7ddccf0986ffbf9d2cb804e8 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Fri, 17 Feb 2023 21:08:46 +0100
Subject: [PATCH 186/992] fix(ui): don't close on BufLeave. Fixes #561
---
lua/lazy/view/float.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index f0e719a..c87ac53 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -53,7 +53,7 @@ function M:init(opts)
}
self:mount()
self:on_key(ViewConfig.keys.close, self.close)
- self:on({ "BufDelete", "BufLeave", "BufHidden" }, self.close, { once = true })
+ self:on({ "BufDelete", "BufHidden" }, self.close, { once = true })
return self
end
From 43496fa82cd4d68523754c3492660a9883e747d9 Mon Sep 17 00:00:00 2001
From: Lucas Tavares
Date: Mon, 20 Feb 2023 04:31:03 -0300
Subject: [PATCH 187/992] fix(ui): disable colorcolumn on floating window
(#575)
---
lua/lazy/view/float.lua | 1 +
1 file changed, 1 insertion(+)
diff --git a/lua/lazy/view/float.lua b/lua/lazy/view/float.lua
index c87ac53..974fb8e 100644
--- a/lua/lazy/view/float.lua
+++ b/lua/lazy/view/float.lua
@@ -111,6 +111,7 @@ function M:mount()
vim.wo[self.win].spell = false
vim.wo[self.win].wrap = true
vim.wo[self.win].winhighlight = "Normal:LazyNormal"
+ vim.wo[self.win].colorcolumn = ""
end
opts()
From 8d5553d11b22754f7b2e091c8579eff3b477c7bc Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 20 Feb 2023 07:31:46 +0000
Subject: [PATCH 188/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 488 +++++++++++++++++++++++++++-------------------
1 file changed, 285 insertions(+), 203 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index 5753584..ffe7a2a 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,36 +1,32 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 17
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 20
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
1. lazy.nvim |lazy.nvim-lazy.nvim|
- - Features |lazy.nvim-features|
- - Requirements |lazy.nvim-requirements|
- - Installation |lazy.nvim-installation|
- - Plugin Spec |lazy.nvim-plugin-spec|
- - Configuration |lazy.nvim-configuration|
- - Usage |lazy.nvim-usage|
- - Lockfile `lazy-lock.json` |lazy.nvim-lockfile-`lazy-lock.json`|
- - Performance |lazy.nvim-performance|
- - Debug |lazy.nvim-debug|
- - Startup Sequence |lazy.nvim-startup-sequence|
- - Structuring Your Plugins |lazy.nvim-structuring-your-plugins|
- - Migration Guide |lazy.nvim-migration-guide|
- - Uninstalling |lazy.nvim-uninstalling|
- - Highlight Groups |lazy.nvim-highlight-groups|
- - Other Neovim Plugin Managers in Lua|lazy.nvim-other-neovim-plugin-managers-in-lua|
+ - Features |lazy.nvim-lazy.nvim-features|
+ - Requirements |lazy.nvim-lazy.nvim-requirements|
+ - Installation |lazy.nvim-lazy.nvim-installation|
+ - Plugin Spec |lazy.nvim-lazy.nvim-plugin-spec|
+ - Configuration |lazy.nvim-lazy.nvim-configuration|
+ - Usage |lazy.nvim-lazy.nvim-usage|
+ - Lockfile lazy-lock.json |lazy.nvim-lazy.nvim-lockfile-lazy-lock.json|
+ - Performance |lazy.nvim-lazy.nvim-performance|
+ - Debug |lazy.nvim-lazy.nvim-debug|
+ - Startup Sequence |lazy.nvim-lazy.nvim-startup-sequence|
+ - Structuring Your Plugins |lazy.nvim-lazy.nvim-structuring-your-plugins|
+ - Migration Guide |lazy.nvim-lazy.nvim-migration-guide|
+ - Uninstalling |lazy.nvim-lazy.nvim-uninstalling|
+ - Highlight Groups |lazy.nvim-lazy.nvim-highlight-groups|
+ - Other Neovim Plugin Managers in Lua|lazy.nvim-lazy.nvim-other-neovim-plugin-managers-in-lua|
==============================================================================
1. lazy.nvim *lazy.nvim-lazy.nvim*
**lazy.nvim** is a modern plugin manager for Neovim.
-
-FEATURES *lazy.nvim-features*
+FEATURES *lazy.nvim-lazy.nvim-features*
- Manage all your Neovim plugins with a powerful UI
@@ -52,15 +48,15 @@ FEATURES *lazy.nvim-features*
- Automatically lazy-loads colorschemes
-REQUIREMENTS *lazy.nvim-requirements*
+REQUIREMENTS *lazy.nvim-lazy.nvim-requirements*
- Neovim >= **0.8.0** (needs to be built with **LuaJIT**)
- Git >= **2.19.0** (for partial clones support)
-- a Nerd Font **_(optional)_**
+- a Nerd Font **(optional)**
-INSTALLATION *lazy.nvim-installation*
+INSTALLATION *lazy.nvim-lazy.nvim-installation*
You can add the following Lua code to your `init.lua` to bootstrap
**lazy.nvim**
@@ -80,7 +76,6 @@ You can add the following Lua code to your `init.lua` to bootstrap
vim.opt.rtp:prepend(lazypath)
<
-
Next step is to add **lazy.nvim** below the code added in the last step in
`init.lua`
@@ -89,12 +84,10 @@ Next step is to add **lazy.nvim** below the code added in the last step in
<
-
-- **plugins**: this should be a `table` or a `string`
- - `table`: a list with your |lazy.nvim-plugin-spec|
- - `string`: a Lua module name that contains your |lazy.nvim-plugin-spec|. See |lazy.nvim-structuring-your-plugins|
-- **opts**: see |lazy.nvim-configuration| **_(optional)_**
-
+- **plugins**this should be a `table` or a `string`
+ - `table`a list with your |lazy.nvim-plugin-spec|
+ - `string`a Lua module name that contains your |lazy.nvim-plugin-spec|. See |lazy.nvim-structuring-your-plugins|
+- **opts**see |lazy.nvim-configuration| **(optional)**
>lua
-- example using a list of specs with the default options
@@ -107,38 +100,102 @@ Next step is to add **lazy.nvim** below the code added in the last step in
})
<
-
It is recommended to run `:checkhealth lazy` after installation
-PLUGIN SPEC *lazy.nvim-plugin-spec*
-│ Property │ Type │ Description │
-│[1] │string? │Short plugin url. Will be expanded using config.git.url_format │
-│**dir** │string? │A directory pointing to a local plugin │
-│**url** │string? │A custom git url where the plugin is hosted │
-│**name** │string? │A custom name for the plugin used for the local plugin directory and as the display name │
-│**dev** │boolean? │When true, a local plugin directory will be used instead. See config.dev │
-│**lazy** │boolean? │When true, the plugin will only be loaded when needed. Lazy-loaded plugins are automatically loaded when their Lua modules are required, or when one of the lazy-loading handlers triggers │
-│**enabled** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be included in the spec │
-│**cond** │boolean? or fun():boolean │When false, or if the function returns false, then this plugin will not be loaded. Useful to disable some plugins in vscode, or firenvim for example. │
-│**dependencies**│LazySpec[] │A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. │
-│**init** │fun(LazyPlugin) │init functions are always executed during startup │
-│**opts** │table or fun(LazyPlugin, opts:table) │opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config() │
-│**config** │fun(LazyPlugin, opts:table) or true │config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). "plugin" will default to name if specified, otherwise lazy.nvim will do its best to guess the correct plugin name. See also opts. To use the default implementation without opts set config to true. │
-│**build** │fun(LazyPlugin) or string or a list of build commands │build is executed when a plugin is installed or updated. If it’s a string it will be ran as a shell command. When prefixed with : it is a Neovim command. You can also specify a list to executed multiple build commands │
-│**branch** │string? │Branch of the repository │
-│**tag** │string? │Tag of the repository │
-│**commit** │string? │Commit of the repository │
-│**version** │string? │Version to use from the repository. Full Semver ranges are supported │
-│**pin** │boolean? │When true, this plugin will not be included in updates │
-│submodules │boolean? │When false, git submodules will not be fetched. Defaults to true │
-│**event** │string? or string[] or fun(self:LazyPlugin, event:string[]):string[] │Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter .lua │
-│**cmd** │string? or string[] or fun(self:LazyPlugin, cmd:string[]):string[] │Lazy-load on command │
-│**ft** │string? or string[] or fun(self:LazyPlugin, ft:string[]):string[] │Lazy-load on filetype │
-│**keys** │string? or string[] or LazyKeys[] or fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[] │Lazy-load on key mapping │
-│**module** │false? │Do not automatically load this Lua module when it’s required somewhere │
-│**priority** │number? │Only useful for **start** plugins (lazy=false) to force loading certain plugins first. Default priority is 50. It’s recommended to set this to a high number for colorschemes. │
+PLUGIN SPEC *lazy.nvim-lazy.nvim-plugin-spec*
+ --------------------------------------------------------------------------------------------------------------------------------
+ Property Type Description
+ -------------- ------------------------------------------------------------ ----------------------------------------------------
+ [1] string? Short plugin url. Will be expanded using
+ config.git.url_format
+
+ dir string? A directory pointing to a local plugin
+
+ url string? A custom git url where the plugin is hosted
+
+ name string? A custom name for the plugin used for the local
+ plugin directory and as the display name
+
+ dev boolean? When true, a local plugin directory will be used
+ instead. See config.dev
+
+ lazy boolean? When true, the plugin will only be loaded when
+ needed. Lazy-loaded plugins are automatically loaded
+ when their Lua modules are required, or when one of
+ the lazy-loading handlers triggers
+
+ enabled boolean? or fun():boolean When false, or if the function returns false, then
+ this plugin will not be included in the spec
+
+ cond boolean? or fun():boolean When false, or if the function returns false, then
+ this plugin will not be loaded. Useful to disable
+ some plugins in vscode, or firenvim for example.
+
+ dependencies LazySpec[] A list of plugin names or plugin specs that should
+ be loaded when the plugin loads. Dependencies are
+ always lazy-loaded unless specified otherwise. When
+ specifying a name, make sure the plugin spec has
+ been defined somewhere else.
+
+ init fun(LazyPlugin) init functions are always executed during startup
+
+ opts table or fun(LazyPlugin, opts:table) opts should be a table (will be merged with parent
+ specs), return a table (replaces parent specs) or
+ should change a table. The table will be passed to
+ the Plugin.config() function. Setting this value
+ will imply Plugin.config()
+
+ config fun(LazyPlugin, opts:table) or true config is executed when the plugin loads. The
+ default implementation will automatically run
+ require("plugin").setup(opts). "plugin" will default
+ to name if specified, otherwise lazy.nvim will do
+ its best to guess the correct plugin name. See also
+ opts. To use the default implementation without opts
+ set config to true.
+
+ build fun(LazyPlugin) or string or a list of build commands build is executed when a plugin is installed or
+ updated. If it’s a string it will be ran as a shell
+ command. When prefixed with it is a Neovim command.
+ You can also specify a list to executed multiple
+ build commands
+
+ branch string? Branch of the repository
+
+ tag string? Tag of the repository
+
+ commit string? Commit of the repository
+
+ version string? Version to use from the repository. Full Semver
+ ranges are supported
+
+ pin boolean? When true, this plugin will not be included in
+ updates
+
+ submodules boolean? When false, git submodules will not be fetched.
+ Defaults to true
+
+ event string? or string[] or Lazy-load on event. Events can be specified as
+ fun(self:LazyPlugin, event:string[]):string[] BufEnter or with a pattern like BufEnter .lua
+
+ cmd string? or string[] or Lazy-load on command
+ fun(self:LazyPlugin, cmd:string[]):string[]
+
+ ft string? or string[] or Lazy-load on filetype
+ fun(self:LazyPlugin, ft:string[]):string[]
+
+ keys string? or string[] or LazyKeys[] or Lazy-load on key mapping
+ fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[]
+
+ module false? Do not automatically load this Lua module when it’s
+ required somewhere
+
+ priority number? Only useful for start plugins (lazy=false) to force
+ loading certain plugins first. Default priority is
+ 50. It’s recommended to set this to a high number
+ for colorschemes.
+ --------------------------------------------------------------------------------------------------------------------------------
LAZY LOADING ~
@@ -157,45 +214,36 @@ You can configure **lazy.nvim** to lazy-load all plugins by default with
Additionally, you can also lazy-load on **events**, **commands**, **file
types** and **key mappings**.
-Plugins will be lazy-loaded when one of the following is `true`:
+Plugins will be lazy-loaded when one of the following is `true`
-- the plugin only exists as a dependency in your spec
+- theplugin only exists as a dependency in your spec
- it has an `event`, `cmd`, `ft` or `keys` key
- `config.defaults.lazy == true`
- *lazy.nvim-Colorschemes*
-
-Colorschemes Colorscheme plugins can be configured
- with `lazy=true`. The plugin will
- automagically load when doing
- `colorscheme foobar`.
+COLORSCHEMES
+Colorscheme plugins can be configured with `lazy=true`. The plugin will
+automagically load when doing `colorscheme foobar`.
**NOTE:** since **start** plugins can possibly change existing highlight
groups, it’s important to make sure that your main **colorscheme** is loaded
- first. To ensure this you can use the `priority=1000` field. **_(see the
- examples)_**
+ first. To ensure this you can use the `priority=1000` field. **(see the
+ examples)**
+
+LAZY KEY MAPPINGS
+
+The `keys` property can be a `string` or `string[]` for simple normal-mode
+mappings, or it can be a `LazyKeys` table with the following key-value pairs:
- *lazy.nvim-Lazy-Key-Mappings*
-
-Lazy Key Mappings The `keys` property can be a `string` or
- `string[]` for simple normal-mode
- mappings, or it can be a `LazyKeys`
- table with the following key-value
- pairs:
-
-
-
-- **[1]**: (`string`) lhs **_(required)_**
-- **[2]**: (`string|fun()`) rhs **_(optional)_**
-- **mode**: (`string|string[]`) mode **_(optional, defaults to `"n"`)_**
+- **[1]**(`string`) lhs **(required)**
+- **[2]**(`string|fun()`) rhs **(optional)**
+- **mode**(`string|string[]`) mode **(optional, defaults to "n")**
- any other option valid for `vim.keymap.set`
-
Key mappings will load the plugin the first time they get executed.
When `[2]` is `nil`, then the real mapping has to be created by the `config()`
@@ -222,22 +270,22 @@ If you want to install a specific revision of a plugin, you can use `commit`,
The `version` property supports Semver ranges.
-Click to see some examples
+Click to see some examples ~
-- :latest stable version (this excludes pre-release versions)
-- `1.2.x`: any version that starts with `1.2`, such as `1.2.0`, `1.2.3`, etc.
-- `^1.2.3`: any version that is compatible with `1.2.3`, such as `1.3.0`, `1.4.5`, etc., but not `2.0.0`.
-- `~1.2.3`: any version that is compatible with `1.2.3`, such as `1.2.4`, `1.2.5`, but not `1.3.0`.
-- `>1.2.3`: any version that is greater than `1.2.3`, such as `1.3.0`, `1.4.5`, etc.
-- `>=1.2.3`: any version that is greater than or equal to `1.2.3`, such as `1.2.3`, `1.3.0`, `1.4.5`, etc.
-- `<1.2.3`: any version that is less than `1.2.3`, such as `1.1.0`, `1.0.5`, etc.
-- `<=1.2.3`: any version that is less than or equal to `1.2.3`, such as `1.2.3`, `1.1.0`, `1.0.5`, etc
-
+- latest stable version (this excludes pre-release versions)
+- `1.2.x`any version that starts with `1.2`, such as `1.2.0`, `1.2.3`, etc.
+- `^1.2.3`any version that is compatible with `1.2.3`, such as `1.3.0`, `1.4.5`, etc., but not `2.0.0`.
+- `~1.2.3`any version that is compatible with `1.2.3`, such as `1.2.4`, `1.2.5`, but not `1.3.0`.
+- `>1.2.3`any version that is greater than `1.2.3`, such as `1.3.0`, `1.4.5`, etc.
+- `>=1.2.3`any version that is greater than or equal to `1.2.3`, such as `1.2.3`, `1.3.0`, `1.4.5`, etc.
+- `<1.2.3`any version that is less than `1.2.3`, such as `1.1.0`, `1.0.5`, etc.
+- `<=1.2.3`any version that is less than or equal to `1.2.3`, such as `1.2.3`, `1.1.0`, `1.0.5`, etc
You can set `config.defaults.version = ""` to install the latest stable version
of plugins that support Semver.
+
EXAMPLES ~
>lua
@@ -338,7 +386,7 @@ EXAMPLES ~
<
-CONFIGURATION *lazy.nvim-configuration*
+CONFIGURATION *lazy.nvim-lazy.nvim-configuration*
**lazy.nvim** comes with the following defaults:
@@ -486,8 +534,7 @@ CONFIGURATION *lazy.nvim-configuration*
}
<
-
-If you don’t want to use a Nerd Font, you can replace the icons with Unicode symbols.
+If you don’t want to use a Nerd Font, you can replace the icons with Unicode symbols. ~
>lua
{
@@ -511,7 +558,7 @@ If you don’t want to use a Nerd Font, you can replace the icons with Unicode s
<
-USAGE *lazy.nvim-usage*
+USAGE *lazy.nvim-lazy.nvim-usage*
Plugins are managed with the `:Lazy` command. Open the help with `>` to see
all the key mappings.
@@ -526,24 +573,43 @@ enabled with `config.checker.enabled = true`.
Any operation can be started from the UI, with a sub command or an API
function:
-│ Command │ Lua │ Description │
-│:Lazy build {plugins} │require("lazy").build(opts) │Rebuild a plugin │
-│:Lazy check [plugins] │require("lazy").check(opts?) │Check for updates and show the log (git fetch) │
-│:Lazy clean [plugins] │require("lazy").clean(opts?) │Clean plugins that are no longer needed │
-│:Lazy clear │require("lazy").clear() │Clear finished tasks │
-│:Lazy debug │require("lazy").debug() │Show debug information │
-│:Lazy health │require("lazy").health() │Run :checkhealth lazy │
-│:Lazy help │require("lazy").help() │Toggle this help page │
-│:Lazy home │require("lazy").home() │Go back to plugin list │
-│:Lazy install [plugins] │require("lazy").install(opts?) │Install missing plugins │
-│:Lazy load {plugins} │require("lazy").load(opts) │Load a plugin that has not been loaded yet. Similar to :packadd. Like :Lazy load foo.nvim. Use :Lazy! load to skip cond checks. │
-│:Lazy log [plugins] │require("lazy").log(opts?) │Show recent updates │
-│:Lazy profile │require("lazy").profile() │Show detailed profiling │
-│:Lazy restore [plugins] │require("lazy").restore(opts?) │Updates all plugins to the state in the lockfile. For a single plugin: restore it to the state in the lockfile or to a given commit under the cursor│
-│:Lazy sync [plugins] │require("lazy").sync(opts?) │Run install, clean and update │
-│:Lazy update [plugins] │require("lazy").update(opts?) │Update plugins. This will also update the lockfile │
+ --------------------------------------------------------------------------------------------------------------
+ Command Lua Description
+ ------------------------- -------------------------------- ---------------------------------------------------
+ :Lazy build {plugins} require("lazy").build(opts) Rebuild a plugin
+ :Lazy check [plugins] require("lazy").check(opts?) Check for updates and show the log (git fetch)
+ :Lazy clean [plugins] require("lazy").clean(opts?) Clean plugins that are no longer needed
+
+ :Lazy clear require("lazy").clear() Clear finished tasks
+
+ :Lazy debug require("lazy").debug() Show debug information
+
+ :Lazy health require("lazy").health() Run :checkhealth lazy
+
+ :Lazy help require("lazy").help() Toggle this help page
+
+ :Lazy home require("lazy").home() Go back to plugin list
+
+ :Lazy install [plugins] require("lazy").install(opts?) Install missing plugins
+
+ :Lazy load {plugins} require("lazy").load(opts) Load a plugin that has not been loaded yet. Similar
+ to :packadd. Like :Lazy load foo.nvim. Use
+ :Lazy! load to skip cond checks.
+
+ :Lazy log [plugins] require("lazy").log(opts?) Show recent updates
+
+ :Lazy profile require("lazy").profile() Show detailed profiling
+
+ :Lazy restore [plugins] require("lazy").restore(opts?) Updates all plugins to the state in the lockfile.
+ For a single plugin: restore it to the state in the
+ lockfile or to a given commit under the cursor
+
+ :Lazy sync [plugins] require("lazy").sync(opts?) Run install, clean and update
+
+ :Lazy update [plugins] require("lazy").update(opts?) Update plugins. This will also update the lockfile
+ --------------------------------------------------------------------------------------------------------------
Any command can have a **bang** to make the command wait till it finished. For
example, if you want to sync lazy from the cmdline, you can use:
@@ -551,15 +617,13 @@ example, if you want to sync lazy from the cmdline, you can use:
$ nvim --headless "+Lazy! sync" +qa
<
-
`opts` is a table with the following key-values:
-- **wait**: when true, then the call will wait till the operation completed
-- **show**: when false, the UI will not be shown
-- **plugins**: a list of plugin names to run the operation on
-- **concurrency**: limit the `number` of concurrently running tasks
-
+- **wait**when true, then the call will wait till the operation completed
+- **show**when false, the UI will not be shown
+- **plugins**a list of plugin names to run the operation on
+- **concurrency**limit the `number` of concurrently running tasks
Stats API (`require("lazy").stats()`):
@@ -578,12 +642,11 @@ Stats API (`require("lazy").stats()`):
}
<
-
**lazy.nvim** provides a statusline component that you can use to show the
number of pending updates. Make sure to enable `config.checker.enabled = true`
to make this work.
-Example of configuring lualine.nvim
+Example of configuring lualine.nvim ~
>lua
require("lualine").setup({
@@ -605,20 +668,20 @@ USER EVENTS ~
The following user events will be triggered:
-- **LazyDone**: when lazy has finished starting up and loaded your config
-- **LazySync**: after running sync
-- **LazyInstall**: after an install
-- **LazyUpdate**: after an update
-- **LazyClean**: after a clean
-- **LazyCheck**: after checking for updates
-- **LazyLog**: after running log
-- **LazyReload**: triggered by change detection after reloading plugin specs
-- **VeryLazy**: triggered after `LazyDone` and processing `VimEnter` auto commands
-- **LazyVimStarted**: triggered after `UIEnter` when `require("lazy").stats().startuptime` has been calculated.
+- **LazyDone**when lazy has finished starting up and loaded your config
+- **LazySync**after running sync
+- **LazyInstall**after an install
+- **LazyUpdate**after an update
+- **LazyClean**after a clean
+- **LazyCheck**after checking for updates
+- **LazyLog**after running log
+- **LazyReload**triggered by change detection after reloading plugin specs
+- **VeryLazy**triggered after `LazyDone` and processing `VimEnter` auto commands
+- **LazyVimStarted**triggered after `UIEnter` when `require("lazy").stats().startuptime` has been calculated.
Useful to update the startuptime on your dashboard.
-LOCKFILE `LAZY-LOCK.JSON` *lazy.nvim-lockfile-`lazy-lock.json`*
+LOCKFILE LAZY-LOCK.JSON *lazy.nvim-lazy.nvim-lockfile-lazy-lock.json*
After every **update**, the local lockfile is updated with the installed
revisions. It is recommended to have this file under version control.
@@ -629,7 +692,8 @@ ensure that the same version of every plugin is installed.
If you are on another machine, you can do `:Lazy restore`, to update all your
plugins to the version from the lockfile.
-PERFORMANCE *lazy.nvim-performance*
+
+PERFORMANCE *lazy.nvim-lazy.nvim-performance*
Great care has been taken to make the startup code (`lazy.core`) as efficient
as possible. During startup, all Lua files used before `VimEnter` or
@@ -643,22 +707,14 @@ lazy-loading though :)
improve performance. The profiling view shows you why and how long it took to
load your plugins.
-
-DEBUG *lazy.nvim-debug*
+DEBUG *lazy.nvim-lazy.nvim-debug*
See an overview of active lazy-loading handlers and what’s in the module
cache
-
-STARTUP SEQUENCE *lazy.nvim-startup-sequence*
+STARTUP SEQUENCE *lazy.nvim-lazy.nvim-startup-sequence*
**lazy.nvim** does **NOT** use Neovim packages and even disables plugin loading
completely (`vim.go.loadplugins = false`). It takes over the complete startup
@@ -667,15 +723,12 @@ sequence for more flexibility and better performance.
In practice this means that step 10 of |Neovim Initialization| is done by Lazy:
-1. all the plugins’ `init()` functions are executed
-2. all plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)
-3. all files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)
-4. all `/after/plugin` files are sourced (this includes `/after` from plugins)
-
+1. all the plugins’ `init()` functions are executed2. all plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)3. all files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)4. all `/after/plugin` files are sourced (this includes `/after` from plugins)
Files from runtime directories are always sourced in alphabetical order.
-STRUCTURING YOUR PLUGINS *lazy.nvim-structuring-your-plugins*
+
+STRUCTURING YOUR PLUGINS *lazy.nvim-lazy.nvim-structuring-your-plugins*
Some users may want to split their plugin specs in multiple files. Instead of
passing a spec table to `setup()`, you can use a Lua module. The specs from the
@@ -690,21 +743,17 @@ The benefits of using this approach:
- allows for **caching** of all your plugin specs. This becomes important if you have a lot of smaller plugin specs.
- spec changes will automatically be **reloaded** when they’re updated, so the `:Lazy` UI is always up to date
-
Example:
- `~/.config/nvim/init.lua`
-
>lua
require("lazy").setup("plugins")
<
-
-- `~/.config/nvim/lua/plugins.lua` or `~/.config/nvim/lua/plugins/init.lua` **_(this file is optional)_**
-
+- `~/.config/nvim/lua/plugins.lua` or `~/.config/nvim/lua/plugins/init.lua` **(this file is optional)**
>lua
return {
@@ -715,10 +764,8 @@ Example:
<
-
- any lua file in `~/.config/nvim/lua/plugins/.lua` will be automatically merged in the main plugin spec
-
For a real-life example, you can check LazyVim
and more specifically:
@@ -726,7 +773,7 @@ For a real-life example, you can check LazyVim
- lazyvim.plugins contains all the plugin specs that will be loaded
-IMPORTING SPECS, `CONFIG` & `OPTS` ~
+IMPORTING SPECS, CONFIG & OPTS ~
As part of a spec, you can add `import` statements to import additional plugin
modules. Both of the `setup()` calls are equivalent:
@@ -738,7 +785,6 @@ modules. Both of the `setup()` calls are equivalent:
require("lazy").setup({{import = "plugins"}})
<
-
When you import specs, you can override them by simply adding a spec for the
same plugin to your local specs, adding any keys you want to override / merge.
@@ -746,9 +792,11 @@ same plugin to your local specs, adding any keys you want to override / merge.
the parent spec. Any other property will override the property from the parent
spec.
-MIGRATION GUIDE *lazy.nvim-migration-guide*
-PACKER.NVIM ~
+MIGRATION GUIDE *lazy.nvim-lazy.nvim-migration-guide*
+
+
+PACKER.NVIM ~
- `setup` `init`
@@ -759,21 +807,19 @@ PACKER.NVIM ~
- `lock` `pin`
- `disable=true` `enabled = false`
- `tag=''` `version=""`
-- `after` **_not needed_** for most use-cases. Use `dependencies` otherwise.
-- `wants` **_not needed_** for most use-cases. Use `dependencies` otherwise.
+- `after` **not needed** for most use-cases. Use `dependencies` otherwise.
+- `wants` **not needed** for most use-cases. Use `dependencies` otherwise.
- `config` don’t support string type, use `fun(LazyPlugin)` instead.
- `module` is auto-loaded. No need to specify
- `keys` spec is |lazy.nvim-different|
- `rtp` can be accomplished with:
-
>lua
config = function(plugin)
vim.opt.rtp:append(plugin.dir .. "/custom-rtp")
end
<
-
With packer `wants`, `requires` and `after` can be used to manage dependencies.
With lazy, this isn’t needed for most of the lua dependencies. They can be
installed just like normal plugins (even with `lazy=true`) and will be loaded
@@ -782,7 +828,8 @@ required plugins with the one that requires them. The plugins which are added
as `dependencies` will always be lazy-loaded and loaded when the plugin is
loaded.
-PAQ-NVIM ~
+
+PAQ-NVIM ~
- `as` `name`
@@ -790,58 +837,87 @@ PAQ-NVIM ~
- `run` `build`
-UNINSTALLING *lazy.nvim-uninstalling*
+UNINSTALLING *lazy.nvim-lazy.nvim-uninstalling*
To uninstall **lazy.nvim**, you need to remove the following files and
directories:
-- **data**: `~/.local/share/nvim/lazy`
-- **state**: `~/.local/state/nvim/lazy`
-- **lockfile**: `~/.config/nvim/lazy-lock.json`
-
+- **data**`~/.local/share/nvim/lazy`
+- **state**`~/.local/state/nvim/lazy`
+- **lockfile**`~/.config/nvim/lazy-lock.json`
paths can differ if you changed `XDG` environment variables.
+HIGHLIGHT GROUPS *lazy.nvim-lazy.nvim-highlight-groups*
-HIGHLIGHT GROUPS *lazy.nvim-highlight-groups*
+Click to see all highlight groups ~
-Click to see all highlight groups
+ ---------------------------------------------------------------------------------
+ Highlight Group Default Group Description
+ ------------------- ------------------------ ------------------------------------
+ LazyButton CursorLine
-│ Highlight Group │ Default Group │ Description │
-│**LazyButton** │**_CursorLine_** │ │
-│**LazyButtonActive** │**_Visual_** │ │
-│**LazyComment** │**_Comment_** │ │
-│**LazyCommit** │_variable.builtin │commitref │
-│**LazyCommitIssue** │**_Number_** │ │
-│**LazyCommitScope** │**_Italic_** │conventional commit scope │
-│**LazyCommitType** │**_Title_** │conventional commit type │
-│**LazyDir** │_text.reference │directory │
-│**LazyH1** │**_IncSearch_** │homebutton │
-│**LazyH2** │**_Bold_** │titles │
-│**LazyNoCond** │**_DiagnosticWarn_**│unloaded icon for a plugin where cond() was false │
-│**LazyNormal** │**_NormalFloat_** │ │
-│**LazyProgressDone** │**_Constant_** │progress bar done │
-│**LazyProgressTodo** │**_LineNr_** │progress bar todo │
-│**LazyProp** │**_Conceal_** │property │
-│**LazyReasonCmd** │**_Operator_** │ │
-│**LazyReasonEvent** │**_Constant_** │ │
-│**LazyReasonFt** │**_Character_** │ │
-│**LazyReasonImport** │**_Identifier_** │ │
-│**LazyReasonKeys** │**_Statement_** │ │
-│**LazyReasonPlugin** │**_Special_** │ │
-│**LazyReasonRuntime**│_macro │ │
-│**LazyReasonSource** │**_Character_** │ │
-│**LazyReasonStart** │_field │ │
-│**LazySpecial** │_punctuation.special│ │
-│**LazyTaskError** │**_ErrorMsg_** │taskerrors │
-│**LazyTaskOutput** │**_MsgArea_** │task output │
-│**LazyUrl** │_text.reference │url │
-│**LazyValue** │_string │valueof a property │
+ LazyButtonActive Visual
+ LazyComment Comment
-OTHER NEOVIM PLUGIN MANAGERS IN LUA*lazy.nvim-other-neovim-plugin-managers-in-lua*
+ LazyCommit _@variable.builtin_ commitref
+
+ LazyCommitIssue Number
+
+ LazyCommitScope Italic conventional commit scope
+
+ LazyCommitType Title conventional commit type
+
+ LazyDir _@text.reference_ directory
+
+ LazyH1 IncSearch homebutton
+
+ LazyH2 Bold titles
+
+ LazyNoCond DiagnosticWarn unloaded icon for a plugin where
+ cond() was false
+
+ LazyNormal NormalFloat
+
+ LazyProgressDone Constant progress bar done
+
+ LazyProgressTodo LineNr progress bar todo
+
+ LazyProp Conceal property
+
+ LazyReasonCmd Operator
+
+ LazyReasonEvent Constant
+
+ LazyReasonFt Character
+
+ LazyReasonImport Identifier
+
+ LazyReasonKeys Statement
+
+ LazyReasonPlugin Special
+
+ LazyReasonRuntime _@macro_
+
+ LazyReasonSource Character
+
+ LazyReasonStart _@field_
+
+ LazySpecial _@punctuation.special_
+
+ LazyTaskError ErrorMsg taskerrors
+
+ LazyTaskOutput MsgArea task output
+
+ LazyUrl _@text.reference_ url
+
+ LazyValue _@string_ valueof a property
+ ---------------------------------------------------------------------------------
+
+OTHER NEOVIM PLUGIN MANAGERS IN LUA*lazy.nvim-lazy.nvim-other-neovim-plugin-managers-in-lua*
- packer.nvim
@@ -851,6 +927,12 @@ OTHER NEOVIM PLUGIN MANAGERS IN LUA*lazy.nvim-other-neovim-plugin-managers-in-lu
- optpack.nvim
- pact.nvim
+==============================================================================
+2. Links *lazy.nvim-links*
+
+1. *image*: https://user-images.githubusercontent.com/292349/208301737-68fb279c-ba70-43ef-a369-8c3e8367d6b1.png
+2. *image*: https://user-images.githubusercontent.com/292349/208301766-5c400561-83c3-4811-9667-1ec4bb3c43b8.png
+3. *image*: https://user-images.githubusercontent.com/292349/208301790-7eedbfa5-d202-4e70-852e-de68aa47233b.png
Generated by panvimdoc
From 8077428e63feb0f3bf795d53b23ba1695b28ab0e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Mon, 20 Feb 2023 09:06:09 +0100
Subject: [PATCH 189/992] chore(main): release 9.8.5 (#563)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
CHANGELOG.md | 8 ++++++++
lua/lazy/core/config.lua | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ed8af5..c4ad0b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## [9.8.5](https://github.com/folke/lazy.nvim/compare/v9.8.4...v9.8.5) (2023-02-20)
+
+
+### Bug Fixes
+
+* **ui:** disable colorcolumn on floating window ([#575](https://github.com/folke/lazy.nvim/issues/575)) ([43496fa](https://github.com/folke/lazy.nvim/commit/43496fa82cd4d68523754c3492660a9883e747d9))
+* **ui:** don't close on BufLeave. Fixes [#561](https://github.com/folke/lazy.nvim/issues/561) ([7339145](https://github.com/folke/lazy.nvim/commit/7339145a223dab7e7ddccf0986ffbf9d2cb804e8))
+
## [9.8.4](https://github.com/folke/lazy.nvim/compare/v9.8.3...v9.8.4) (2023-02-17)
diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua
index 310e11c..bb974f7 100644
--- a/lua/lazy/core/config.lua
+++ b/lua/lazy/core/config.lua
@@ -147,7 +147,7 @@ M.defaults = {
debug = false,
}
-M.version = "9.8.4" -- x-release-please-version
+M.version = "9.8.5" -- x-release-please-version
M.ns = vim.api.nvim_create_namespace("lazy")
From 1657ae9b8c86d672517ac7f573eb180d3f5ecb79 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 27 Feb 2023 09:59:47 +0100
Subject: [PATCH 190/992] fix(keys): set nowait for lazy keymaps when needed.
Fixes #600
---
lua/lazy/core/handler/keys.lua | 1 +
1 file changed, 1 insertion(+)
diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua
index b1fbc6d..91ece7a 100644
--- a/lua/lazy/core/handler/keys.lua
+++ b/lua/lazy/core/handler/keys.lua
@@ -79,6 +79,7 @@ function M:_add(keys)
vim.api.nvim_feedkeys(feed, "i", false)
end, {
desc = opts.desc,
+ nowait = opts.nowait,
-- we do not return anything, but this is still needed to make operator pending mappings work
expr = true,
})
From 8cbd95bd059f791e7e9c8cbbf03c368a8bcad9f0 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 27 Feb 2023 09:00:46 +0000
Subject: [PATCH 191/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index ffe7a2a..b977a14 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 20
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 27
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
From 5694483e8782f4d9a01ea8822166998924df5f00 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 27 Feb 2023 13:42:52 +0100
Subject: [PATCH 192/992] fix(health): whitelist deactivate prop
---
lua/lazy/health.lua | 1 +
1 file changed, 1 insertion(+)
diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua
index 75a85a6..39df32d 100644
--- a/lua/lazy/health.lua
+++ b/lua/lazy/health.lua
@@ -94,6 +94,7 @@ M.valid = {
"commit",
"cond",
"config",
+ "deactivate",
"dependencies",
"dev",
"dir",
From b814d870897a12b636580e397a78acf242a85e93 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 27 Feb 2023 20:25:03 +0100
Subject: [PATCH 193/992] style(cache): removed hack for relative paths
---
lua/lazy/core/cache.lua | 7 -------
1 file changed, 7 deletions(-)
diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua
index 8a02711..6f7c4f5 100644
--- a/lua/lazy/core/cache.lua
+++ b/lua/lazy/core/cache.lua
@@ -231,13 +231,6 @@ function Cache.find(modname, opts)
local basename = modname:gsub("%.", "/")
local idx = modname:find(".", 1, true)
- -- HACK: some plugins try to load invalid relative paths (see #543)
- if idx == 1 then
- modname = modname:gsub("^%.+", "")
- basename = modname:gsub("%.", "/")
- idx = modname:find(".", 1, true)
- end
-
local topmod = idx and modname:sub(1, idx - 1) or modname
-- OPTIM: search for a directory first when topmod == modname
From 9bd1c946d6114affebb57dbe3e33741ded566559 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Mon, 27 Feb 2023 20:38:05 +0100
Subject: [PATCH 194/992] feat(health): check for paths on the rtp from plugged
or packer
---
lua/lazy/health.lua | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua
index 39df32d..c982a37 100644
--- a/lua/lazy/health.lua
+++ b/lua/lazy/health.lua
@@ -30,6 +30,15 @@ function M.check()
vim.health.report_ok("no existing packages found by other package managers")
end
+ for _, name in ipairs({ "packer", "plugged", "paq" }) do
+ for _, path in ipairs(vim.opt.rtp:get()) do
+ if path:find(name, 1, true) then
+ vim.health.report_error("Found paths on the rtp from another plugin manager `" .. name .. "`")
+ break
+ end
+ end
+ end
+
local packer_compiled = vim.fn.stdpath("config") .. "/plugin/packer_compiled.lua"
if vim.loop.fs_stat(packer_compiled) then
vim.health.report_error("please remove the file `" .. packer_compiled .. "`")
From c7a8e702f7342a592c8e88e516c206e3226400b4 Mon Sep 17 00:00:00 2001
From: adrian5
Date: Tue, 28 Feb 2023 07:27:19 +0100
Subject: [PATCH 195/992] docs: update some wording and capitalization (#576)
---
README.md | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/README.md b/README.md
index 37fa84f..e0ecbd4 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,9 @@
## ✨ Features
- 📦 Manage all your Neovim plugins with a powerful UI
-- 🚀 Fast startup times thanks to automatic caching and bytecode compilation of lua modules
+- 🚀 Fast startup times thanks to automatic caching and bytecode compilation of Lua modules
- 💾 Partial clones instead of shallow clones
-- 🔌 Automatic lazy-loading of lua modules and lazy-loading on events, commands, filetypes, and key mappings
+- 🔌 Automatic lazy-loading of Lua modules and lazy-loading on events, commands, filetypes, and key mappings
- ⏳ Automatically install missing plugins before starting up Neovim, allowing you to start using it right away
- 💪 Async execution for improved performance
- 🛠️ No need to manually compile plugins
@@ -32,7 +32,7 @@
## 📦 Installation
-You can add the following Lua code to your `init.lua` to bootstrap **lazy.nvim**
+You can add the following Lua code to your `init.lua` to bootstrap **lazy.nvim**:
@@ -53,7 +53,7 @@ vim.opt.rtp:prepend(lazypath)
-Next step is to add **lazy.nvim** below the code added in the last step in `init.lua`
+Next step is to add **lazy.nvim** below the code added in the prior step in `init.lua`:
```lua
require("lazy").setup(plugins, opts)
@@ -65,8 +65,8 @@ require("lazy").setup(plugins, opts)
- **opts**: see [Configuration](#%EF%B8%8F-configuration) **_(optional)_**
```lua
--- example using a list of specs with the default options
-vim.g.mapleader = " " -- make sure to set `mapleader` before lazy so your mappings are correct
+-- Example using a list of specs with the default options
+vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct
require("lazy").setup({
"folke/which-key.nvim",
@@ -75,7 +75,7 @@ require("lazy").setup({
})
```
-ℹ️ It is recommended to run `:checkhealth lazy` after installation
+ℹ️ It is recommended to run `:checkhealth lazy` after installation.
## 🔌 Plugin Spec
@@ -110,7 +110,7 @@ require("lazy").setup({
### Lazy Loading
**lazy.nvim** automagically lazy-loads Lua modules, so it is not needed to
-specify `module=...` everywhere in your plugin specification. This mean that if
+specify `module=...` everywhere in your plugin specification. This means that if
you have a plugin `A` that is lazy-loaded and a plugin `B` that requires a
module of plugin `A`, then plugin `A` will be loaded on demand as expected.
@@ -124,8 +124,8 @@ Additionally, you can also lazy-load on **events**, **commands**,
Plugins will be lazy-loaded when one of the following is `true`:
-- the plugin only exists as a dependency in your spec
-- it has an `event`, `cmd`, `ft` or `keys` key
+- The plugin only exists as a dependency in your spec
+- It has an `event`, `cmd`, `ft` or `keys` key
- `config.defaults.lazy == true`
#### 🌈 Colorschemes
@@ -605,7 +605,7 @@ The profiling view shows you why and how long it took to load your plugins.
## 🐛 Debug
-See an overview of active lazy-loading handlers and what's in the module cache
+See an overview of active lazy-loading handlers and what's in the module cache.

@@ -617,10 +617,10 @@ startup sequence for more flexibility and better performance.
In practice this means that step 10 of [Neovim Initialization](https://neovim.io/doc/user/starting.html#initialization) is done by Lazy:
-1. all the plugins' `init()` functions are executed
-2. all plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)
-3. all files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)
-4. all `/after/plugin` files are sourced (this includes `/after` from plugins)
+1. All the plugins' `init()` functions are executed
+2. All plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)
+3. All files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)
+4. All `/after/plugin` files are sourced (this includes `/after` from plugins)
Files from runtime directories are always sourced in alphabetical order.
@@ -633,9 +633,9 @@ so it is not needed to add `require` calls in your main plugin file to the other
The benefits of using this approach:
-- simple to **add** new plugin specs. Just create a new file in your plugins module.
-- allows for **caching** of all your plugin specs. This becomes important if you have a lot of smaller plugin specs.
-- spec changes will automatically be **reloaded** when they're updated, so the `:Lazy` UI is always up to date
+- Simple to **add** new plugin specs. Just create a new file in your plugins module.
+- Allows for **caching** of all your plugin specs. This becomes important if you have a lot of smaller plugin specs.
+- Spec changes will automatically be **reloaded** when they're updated, so the `:Lazy` UI is always up to date.
Example:
@@ -655,7 +655,7 @@ return {
}
```
-- any lua file in `~/.config/nvim/lua/plugins/*.lua` will be automatically merged in the main plugin spec
+- Any lua file in `~/.config/nvim/lua/plugins/*.lua` will be automatically merged in the main plugin spec
For a real-life example, you can check [LazyVim](https://github.com/LazyVim/LazyVim) and more specifically:
@@ -669,7 +669,7 @@ Both of the `setup()` calls are equivalent:
```lua
require("lazy").setup("plugins")
--- same as:
+-- Same as:
require("lazy").setup({{import = "plugins"}})
```
@@ -705,7 +705,7 @@ end
```
With packer `wants`, `requires` and `after` can be used to manage dependencies.
-With lazy, this isn't needed for most of the lua dependencies. They can be installed just like normal plugins
+With lazy, this isn't needed for most of the Lua dependencies. They can be installed just like normal plugins
(even with `lazy=true`) and will be loaded when other plugins need them.
The `dependencies` key can be used to group those required plugins with the one that requires them.
The plugins which are added as `dependencies` will always be lazy-loaded and loaded when the plugin is loaded.
@@ -724,7 +724,7 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
- **state**: `~/.local/state/nvim/lazy`
- **lockfile**: `~/.config/nvim/lazy-lock.json`
-> paths can differ if you changed `XDG` environment variables.
+> Paths can differ if you changed `XDG` environment variables.
## 🌈 Highlight Groups
From 25132fc08f6c0c68068be19680f8b6d9d6149985 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Tue, 28 Feb 2023 06:28:08 +0000
Subject: [PATCH 196/992] chore(build): auto-generate vimdoc
---
doc/lazy.nvim.txt | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt
index b977a14..ecd4f9b 100644
--- a/doc/lazy.nvim.txt
+++ b/doc/lazy.nvim.txt
@@ -1,4 +1,4 @@
-*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 27
+*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 28
==============================================================================
Table of Contents *lazy.nvim-table-of-contents*
@@ -30,9 +30,9 @@ FEATURES *lazy.nvim-lazy.nvim-features*
- Manage all your Neovim plugins with a powerful UI
-- Fast startup times thanks to automatic caching and bytecode compilation of lua modules
+- Fast startup times thanks to automatic caching and bytecode compilation of Lua modules
- Partial clones instead of shallow clones
-- Automatic lazy-loading of lua modules and lazy-loading on events, commands, filetypes, and key mappings
+- Automatic lazy-loading of Lua modules and lazy-loading on events, commands, filetypes, and key mappings
- Automatically install missing plugins before starting up Neovim, allowing you to start using it right away
- Async execution for improved performance
- No need to manually compile plugins
@@ -76,7 +76,7 @@ You can add the following Lua code to your `init.lua` to bootstrap
vim.opt.rtp:prepend(lazypath)
<
-Next step is to add **lazy.nvim** below the code added in the last step in
+Nextstep is to add **lazy.nvim** below the code added in the prior step in
`init.lua`
>lua
@@ -90,8 +90,8 @@ Next step is to add **lazy.nvim** below the code added in the last step in
- **opts**see |lazy.nvim-configuration| **(optional)**
>lua
- -- example using a list of specs with the default options
- vim.g.mapleader = " " -- make sure to set `mapleader` before lazy so your mappings are correct
+ -- Example using a list of specs with the default options
+ vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct
require("lazy").setup({
"folke/which-key.nvim",
@@ -100,7 +100,7 @@ Next step is to add **lazy.nvim** below the code added in the last step in
})
<
-It is recommended to run `:checkhealth lazy` after installation
+It is recommended to run `:checkhealth lazy` after installation.
PLUGIN SPEC *lazy.nvim-lazy.nvim-plugin-spec*
@@ -200,8 +200,8 @@ PLUGIN SPEC *lazy.nvim-lazy.nvim-plugin-spec*
LAZY LOADING ~
**lazy.nvim** automagically lazy-loads Lua modules, so it is not needed to
-specify `module=...` everywhere in your plugin specification. This mean that if
-you have a plugin `A` that is lazy-loaded and a plugin `B` that requires a
+specify `module=...` everywhere in your plugin specification. This means that
+if you have a plugin `A` that is lazy-loaded and a plugin `B` that requires a
module of plugin `A`, then plugin `A` will be loaded on demand as expected.
If you don’t want this behavior for a certain plugin, you can specify that
@@ -217,8 +217,8 @@ types** and **key mappings**.
Plugins will be lazy-loaded when one of the following is `true`
-- theplugin only exists as a dependency in your spec
-- it has an `event`, `cmd`, `ft` or `keys` key
+- Theplugin only exists as a dependency in your spec
+- It has an `event`, `cmd`, `ft` or `keys` key
- `config.defaults.lazy == true`
@@ -711,7 +711,7 @@ load your plugins.
DEBUG *lazy.nvim-lazy.nvim-debug*
See an overview of active lazy-loading handlers and what’s in the module
-cache
+cache.
STARTUP SEQUENCE *lazy.nvim-lazy.nvim-startup-sequence*
@@ -723,7 +723,7 @@ sequence for more flexibility and better performance.
In practice this means that step 10 of |Neovim Initialization| is done by Lazy:
-1. all the plugins’ `init()` functions are executed2. all plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)3. all files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)4. all `/after/plugin` files are sourced (this includes `/after` from plugins)
+1. All the plugins’ `init()` functions are executed2. All plugins with `lazy=false` are loaded. This includes sourcing `/plugin` and `/ftdetect` files. (`/after` will not be sourced yet)3. All files from `/plugin` and `/ftdetect` directories in you rtp are sourced (excluding `/after`)4. All `/after/plugin` files are sourced (this includes `/after` from plugins)
Files from runtime directories are always sourced in alphabetical order.
@@ -739,9 +739,9 @@ to the other files.
The benefits of using this approach:
-- simple to **add** new plugin specs. Just create a new file in your plugins module.
-- allows for **caching** of all your plugin specs. This becomes important if you have a lot of smaller plugin specs.
-- spec changes will automatically be **reloaded** when they’re updated, so the `:Lazy` UI is always up to date
+- Simple to **add** new plugin specs. Just create a new file in your plugins module.
+- Allows for **caching** of all your plugin specs. This becomes important if you have a lot of smaller plugin specs.
+- Spec changes will automatically be **reloaded** when they’re updated, so the `:Lazy` UI is always up to date.
Example:
@@ -764,7 +764,7 @@ Example:
<
-- any lua file in `~/.config/nvim/lua/plugins/.lua` will be automatically merged in the main plugin spec
+- Any lua file in `~/.config/nvim/lua/plugins/.lua` will be automatically merged in the main plugin spec
For a real-life example, you can check LazyVim
and more specifically:
@@ -781,7 +781,7 @@ modules. Both of the `setup()` calls are equivalent:
>lua
require("lazy").setup("plugins")
- -- same as:
+ -- Same as:
require("lazy").setup({{import = "plugins"}})
<
@@ -821,7 +821,7 @@ PACKER.NVIM ~
<
With packer `wants`, `requires` and `after` can be used to manage dependencies.
-With lazy, this isn’t needed for most of the lua dependencies. They can be
+With lazy, this isn’t needed for most of the Lua dependencies. They can be
installed just like normal plugins (even with `lazy=true`) and will be loaded
when other plugins need them. The `dependencies` key can be used to group those
required plugins with the one that requires them. The plugins which are added
@@ -848,7 +848,7 @@ directories:
- **lockfile**`~/.config/nvim/lazy-lock.json`
- paths can differ if you changed `XDG` environment variables.
+ Paths can differ if you changed `XDG` environment variables.
HIGHLIGHT GROUPS *lazy.nvim-lazy.nvim-highlight-groups*
From 0f713b2958b8a2e624fa0e2615418bd6c8fb8e10 Mon Sep 17 00:00:00 2001
From: Folke Lemaitre
Date: Tue, 28 Feb 2023 09:55:16 +0100
Subject: [PATCH 197/992] fix(ui): always show diagnostics virtual text
---
lua/lazy/view/render.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua
index 6cf424c..b84fb0f 100644
--- a/lua/lazy/view/render.lua
+++ b/lua/lazy/view/render.lua
@@ -84,7 +84,7 @@ function M:update()
diag.lnum = diag.row - 1
return diag
end, self._diagnostics),
- { signs = false }
+ { signs = false, virtual_text = true }
)
end
From 5af93806aaa33fd9e8b4a7a32e9f847a3ad64c2a Mon Sep 17 00:00:00 2001
From: Folke Lemaitre