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: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 2093139..c7949e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # 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) + + +### 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/README.md b/README.md index b5c7b9a..c272438 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 @@ -314,12 +314,17 @@ 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 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. @@ -330,6 +335,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 = { @@ -415,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 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", @@ -438,6 +444,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 } ``` @@ -603,7 +610,7 @@ The profiling view shows you why and how long it took to load your plugins.  -## 🪲 Debug +## 🐛 Debug See an overview of active lazy-loading handlers and what's in the module cache @@ -620,7 +627,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. diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt index caee52f..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 19 +*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 February 01 ============================================================================== Table of Contents *lazy.nvim-table-of-contents* @@ -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| @@ -358,12 +358,17 @@ 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 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. @@ -374,6 +379,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 = { @@ -459,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 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", @@ -482,6 +488,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 } < @@ -647,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 @@ -669,7 +676,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. diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 0140c53..79bef28 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -21,12 +21,17 @@ 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 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. @@ -114,7 +119,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", @@ -141,7 +146,7 @@ M.defaults = { debug = false, } -M.version = "9.3.1" -- x-release-please-version +M.version = "9.5.0" -- x-release-please-version M.ns = vim.api.nvim_create_namespace("lazy") 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 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) 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