From 3f8cc2c0dfa46849c472f4e22247991f2c26db7b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 19 Jan 2023 22:08:58 +0100 Subject: [PATCH 01/80] 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 02/80] 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 03/80] 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 04/80] 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 05/80] 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 06/80] 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 07/80] 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 08/80] 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 09/80] 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 10/80] 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 11/80] 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 12/80] 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 13/80] 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 14/80] 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 15/80] 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 16/80] 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 17/80] 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 18/80] 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 19/80] 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 20/80] 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 21/80] 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 22/80] 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 23/80] 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 24/80] 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. ![image](https://user-images.githubusercontent.com/292349/208301766-5c400561-83c3-4811-9667-1ec4bb3c43b8.png) -## 🪲 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 25/80] 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 26/80] 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 27/80] 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 28/80] 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 29/80] 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 30/80] 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 31/80] 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 32/80] 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 33/80] 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 34/80] 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 35/80] 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 36/80] 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 37/80] 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 38/80] 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 39/80] 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 40/80] 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 41/80] 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 42/80] 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 43/80] 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 44/80] 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 45/80] 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 46/80] 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 47/80] 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 48/80] 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 49/80] 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 50/80] 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 51/80] 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 52/80] 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 53/80] 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 54/80] 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 55/80] 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 56/80] 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 57/80] 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 58/80] 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 59/80] 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 60/80] 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 61/80] 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 62/80] 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 63/80] 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 64/80] 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 65/80] 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 66/80] 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 67/80] 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 68/80] 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 69/80] 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 70/80] 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 71/80] 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 72/80] 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 73/80] 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 74/80] 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 75/80] 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 76/80] 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 77/80] 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 78/80] 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 79/80] 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. -
- -

image

-
-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. -
- -

image

-
-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 -
- -

image

-
-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 80/80] 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")