From 17732094c8352082c949ba635e25768494846477 Mon Sep 17 00:00:00 2001 From: Spencer Gray Date: Mon, 14 Jul 2025 16:17:30 -0400 Subject: [PATCH] fix(health, rockspec): accept Lua 5.1+ for luarocks compatibility Previously, lazy.nvim health checks required exactly Lua 5.1, causing warnings on systems with newer Lua versions (5.2, 5.3, 5.4). This was unnecessarily restrictive since LuaRocks can run on any Lua version 5.1+ to build packages. Its true that Neovim plugins must be Lua 5.1 compatible (due to LuaJIT), but the `--lua-version 5.1` flag tells luarocks to build for 5.1. After some light testing, I verified a system with Lua 5.4 should be able to build Lua 5.1-compatible packages just fine. The key point is that this removes false warnings while maintaining the same safety guarantees - LuaRocks with any modern Lua version can still build packages targeting Lua 5.1 compatibility for Neovim. Closes: #2020 --- lua/lazy/health.lua | 4 ++-- lua/lazy/pkg/rockspec.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua index 6a6d60d..ec9adab 100644 --- a/lua/lazy/health.lua +++ b/lua/lazy/health.lua @@ -43,7 +43,7 @@ function M.have(cmd, opts) else local version = vim.trim(out[1] or "") version = version:gsub("^%s*" .. vim.pesc(c) .. "%s*", "") - if opts.version_pattern and not version:find(opts.version_pattern, 1, true) then + if opts.version_pattern and not version:find(opts.version_pattern) then opts.warn(("`%s` version `%s` needed, but found `%s`"):format(c, opts.version_pattern, version)) else found = ("{%s} `%s`"):format(c, version) @@ -59,7 +59,7 @@ function M.have(cmd, opts) (opts.optional and opts.warn or opts.error)( ("{%s} %snot installed"):format( table.concat(cmd, "} or {"), - opts.version_pattern and "version `" .. opts.version_pattern .. "` " or "" + opts.version_pattern and "version matching `" .. opts.version_pattern .. "` " or "" ) ) end diff --git a/lua/lazy/pkg/rockspec.lua b/lua/lazy/pkg/rockspec.lua index e8ece1b..305a5c5 100644 --- a/lua/lazy/pkg/rockspec.lua +++ b/lua/lazy/pkg/rockspec.lua @@ -82,7 +82,7 @@ function M.check(opts) M.hererocks.bin("lua"), vim.tbl_extend("force", opts, { version = "-v", - version_pattern = "5.1", + version_pattern = "5%.[1-9]", }) ) end @@ -92,7 +92,7 @@ function M.check(opts) { "lua5.1", "lua", "lua-5.1" }, vim.tbl_extend("force", opts, { version = "-v", - version_pattern = "5.1", + version_pattern = "5%.[1-9]", }) ) end