From fb96183753bfc734b081fc5a2a3d5705376d9d20 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 30 Nov 2022 23:12:00 +0100 Subject: [PATCH] feat: allow config of default for version field --- lua/lazy/core/config.lua | 1 + lua/lazy/manage/git.lua | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index f2eeca8b..daef1110 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -7,6 +7,7 @@ M.defaults = { plugins = "config.plugins", defaults = { opt = false, -- should plugins default to "opt" or "start" + version = nil, -- version = "*", -- enable this to try installing the latest stable versions of plugins }, dev = { diff --git a/lua/lazy/manage/git.lua b/lua/lazy/manage/git.lua index 18bfb2a5..df64465a 100644 --- a/lua/lazy/manage/git.lua +++ b/lua/lazy/manage/git.lua @@ -1,5 +1,6 @@ local Util = require("lazy.util") local Semver = require("lazy.manage.semver") +local Config = require("lazy.core.config") local M = {} @@ -89,8 +90,9 @@ function M.get_target(plugin) commit = M.ref(plugin.dir, "tags/" .. plugin.tag), } end - if plugin.version then - local last = Semver.last(M.get_versions(plugin.dir, plugin.version)) + local version = plugin.version or Config.options.defaults.version + if version then + local last = Semver.last(M.get_versions(plugin.dir, version)) if last then return { branch = branch and branch.branch,