From 0d3f2c40421f4774c70f631d7b7023f57cba66cd Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 12 Feb 2023 12:56:42 +0100 Subject: [PATCH] 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?