diff --git a/README.md b/README.md index 93ea123..3ac5b4c 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,7 @@ return { filter = true, }, dev = { - -- directory where you store your local plugin projects + ---@type string | fun(plugin: LazyPlugin): string 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"} @@ -666,7 +666,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`) +3. All files from `/plugin` and `/ftdetect` directories in your 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. @@ -750,8 +750,8 @@ Any other property will override the property from the parent spec. - `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` is **_not needed_** for most use-cases. Use `dependencies` otherwise. +- `wants` is **_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 [different](#%EF%B8%8F-lazy-key-mappings) @@ -836,7 +836,7 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori If your plugin needs a build step, you can create a file `build.lua` or `build/init.lua` in the root of your repo. This file will be loaded when the plugin is installed or updated. -This makes it easier for users, so they no longer need to specify a `build` command. +This makes it easier for users, as they no longer need to specify a `build` command. ## 📦 Other Neovim Plugin Managers in Lua diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt index 4c69064..2fec161 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 November 04 +*lazy.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 January 20 ============================================================================== Table of Contents *lazy.nvim-table-of-contents* @@ -423,7 +423,7 @@ CONFIGURATION *lazy.nvim-lazy.nvim-configuration* filter = true, }, dev = { - -- directory where you store your local plugin projects + ---@type string | fun(plugin: LazyPlugin): string 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"} @@ -768,7 +768,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`) +3. All files from `/plugin` and `/ftdetect` directories in your 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. @@ -859,8 +859,8 @@ 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` is **not needed** for most use-cases. Use `dependencies` otherwise. +- `wants` is **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| @@ -979,7 +979,7 @@ If your plugin needs a build step, you can create a file `build.lua` or `build/init.lua` in the root of your repo. This file will be loaded when the plugin is installed or updated. -This makes it easier for users, so they no longer need to specify a `build` +This makes it easier for users, as they no longer need to specify a `build` command. diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 6336271..459eafe 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -30,7 +30,7 @@ M.defaults = { filter = true, }, dev = { - -- directory where you store your local plugin projects + ---@type string | fun(plugin: LazyPlugin): string 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"} @@ -225,7 +225,9 @@ function M.setup(opts) table.insert(M.options.install.colorscheme, "habamax") M.options.root = Util.norm(M.options.root) - M.options.dev.path = Util.norm(M.options.dev.path) + if type(M.options.dev.path) == "string" then + M.options.dev.path = Util.norm(M.options.dev.path) + end M.options.lockfile = Util.norm(M.options.lockfile) M.options.readme.root = Util.norm(M.options.readme.root) diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua index e19d6e5..6ca2c50 100644 --- a/lua/lazy/core/handler/keys.lua +++ b/lua/lazy/core/handler/keys.lua @@ -41,6 +41,11 @@ function M.parse(value, mode) ret.mode = mode or "n" ret.id = vim.api.nvim_replace_termcodes(ret.lhs, true, true, true) + if ret.ft then + local ft = type(ret.ft) == "string" and { ret.ft } or ret.ft --[[@as string[] ]] + ret.id = ret.id .. " (" .. table.concat(ft, ", ") .. ")" + end + if ret.mode ~= "n" then ret.id = ret.id .. " (" .. ret.mode .. ")" end diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index fc25f8d..64c93cd 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -106,11 +106,16 @@ function Spec:add(plugin, results) end -- dev plugins - if - plugin.dev - and (not Config.options.dev.fallback or vim.fn.isdirectory(Config.options.dev.path .. "/" .. plugin.name) == 1) - then - dir = Config.options.dev.path .. "/" .. plugin.name + if plugin.dev then + local dir_dev + if type(Config.options.dev.path) == "string" then + dir_dev = Config.options.dev.path .. "/" .. plugin.name + else + dir_dev = Util.norm(Config.options.dev.path(plugin)) + end + if not Config.options.dev.fallback or vim.fn.isdirectory(dir_dev) == 1 then + dir = dir_dev + end elseif plugin.dev == false then -- explicitely select the default path dir = Config.options.root .. "/" .. plugin.name diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua index 929092d..89feabe 100644 --- a/lua/lazy/health.lua +++ b/lua/lazy/health.lua @@ -131,6 +131,7 @@ M.valid = { "opts", "pin", "priority", + "submodules", "tag", "url", "version", diff --git a/lua/lazy/manage/git.lua b/lua/lazy/manage/git.lua index 98c44b5..6b0ab58 100644 --- a/lua/lazy/manage/git.lua +++ b/lua/lazy/manage/git.lua @@ -217,7 +217,7 @@ function M.get_config(repo) current_section = section:gsub('%s+"', "."):gsub('"+%s*$', "") else -- Ignore comments and blank lines - if not line:match("^%s*#") and line:match("%S") then + if not line:match("^%s*[#;]") and line:match("%S") then local key, value = line:match("^%s*(%S+)%s*=%s*(.+)%s*$") ret[current_section .. "." .. key] = value end diff --git a/lua/lazy/manage/task/fs.lua b/lua/lazy/manage/task/fs.lua index 525997e..c753143 100644 --- a/lua/lazy/manage/task/fs.lua +++ b/lua/lazy/manage/task/fs.lua @@ -13,7 +13,7 @@ M.clean = { assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!") local stat = vim.loop.fs_lstat(dir) - assert(stat.type == "directory", self.plugin.dir .. " should be a directory!") + assert(stat and stat.type == "directory", self.plugin.dir .. " should be a directory!") Util.walk(dir, function(path, _, type) if type == "directory" then