mirror of https://github.com/folke/lazy.nvim.git
perf(rocks): `vim.fn.executable` is slow on WSL2, so only check for `luarocks` when needed. Closes #1585
This commit is contained in:
parent
8dd947fccd
commit
9ab3061690
|
@ -49,8 +49,11 @@ M.defaults = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
root = vim.fn.stdpath("data") .. "/lazy-rocks",
|
root = vim.fn.stdpath("data") .. "/lazy-rocks",
|
||||||
server = "https://nvim-neorocks.github.io/rocks-binaries/",
|
server = "https://nvim-neorocks.github.io/rocks-binaries/",
|
||||||
-- use hererocks to install luarocks.
|
-- use hererocks to install luarocks?
|
||||||
hererocks = vim.fn.executable("luarocks") == 0,
|
-- set to `nil` to use hererocks when luarocks is not found
|
||||||
|
-- set to `true` to always use hererocks
|
||||||
|
-- set to `false` to always use luarocks
|
||||||
|
hererocks = nil,
|
||||||
},
|
},
|
||||||
dev = {
|
dev = {
|
||||||
---@type string | fun(plugin: LazyPlugin): string directory where you store your local plugin projects
|
---@type string | fun(plugin: LazyPlugin): string directory where you store your local plugin projects
|
||||||
|
@ -218,6 +221,13 @@ M.defaults = {
|
||||||
debug = false,
|
debug = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function M.hererocks()
|
||||||
|
if M.options.rocks.hererocks == nil then
|
||||||
|
M.options.rocks.hererocks = vim.fn.executable("luarocks") == 0
|
||||||
|
end
|
||||||
|
return M.options.rocks.hererocks
|
||||||
|
end
|
||||||
|
|
||||||
M.version = "11.8.1" -- x-release-please-version
|
M.version = "11.8.1" -- x-release-please-version
|
||||||
|
|
||||||
M.ns = vim.api.nvim_create_namespace("lazy")
|
M.ns = vim.api.nvim_create_namespace("lazy")
|
||||||
|
|
|
@ -336,16 +336,16 @@ function M.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add hererocks when enabled and needed
|
-- add hererocks when enabled and needed
|
||||||
if Config.options.rocks.hererocks then
|
for _, plugin in pairs(Config.spec.plugins) do
|
||||||
for _, plugin in pairs(Config.spec.plugins) do
|
if plugin.build == "rockspec" then
|
||||||
if plugin.build == "rockspec" then
|
if Config.hererocks() then
|
||||||
Config.spec.meta:add({
|
Config.spec.meta:add({
|
||||||
"luarocks/hererocks",
|
"luarocks/hererocks",
|
||||||
build = "rockspec",
|
build = "rockspec",
|
||||||
lazy = true,
|
lazy = true,
|
||||||
})
|
})
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ function M.check()
|
||||||
|
|
||||||
start("luarocks")
|
start("luarocks")
|
||||||
if Config.options.rocks.enabled then
|
if Config.options.rocks.enabled then
|
||||||
if Config.options.rocks.hererocks then
|
if Config.hererocks() then
|
||||||
info("checking `hererocks` installation")
|
info("checking `hererocks` installation")
|
||||||
else
|
else
|
||||||
info("checking `luarocks` installation")
|
info("checking `luarocks` installation")
|
||||||
|
@ -155,7 +155,7 @@ function M.check()
|
||||||
"Lazy won't be able to install plugins that require `luarocks`.",
|
"Lazy won't be able to install plugins that require `luarocks`.",
|
||||||
"Here's what you can do:",
|
"Here's what you can do:",
|
||||||
" - fix your `luarocks` installation",
|
" - fix your `luarocks` installation",
|
||||||
Config.options.rocks.hererocks and " - disable *hererocks* with `opts.rocks.hererocks = false`"
|
Config.hererocks() and " - disable *hererocks* with `opts.rocks.hererocks = false`"
|
||||||
or " - enable `hererocks` with `opts.rocks.hererocks = true`",
|
or " - enable `hererocks` with `opts.rocks.hererocks = true`",
|
||||||
" - disable `luarocks` support completely with `opts.rocks.enabled = false`",
|
" - disable `luarocks` support completely with `opts.rocks.enabled = false`",
|
||||||
}, "\n"))
|
}, "\n"))
|
||||||
|
|
|
@ -72,7 +72,7 @@ function M.check(opts)
|
||||||
}, opts or {})
|
}, opts or {})
|
||||||
|
|
||||||
local ok = false
|
local ok = false
|
||||||
if Config.options.rocks.hererocks then
|
if Config.hererocks() then
|
||||||
if M.hererocks.building() then
|
if M.hererocks.building() then
|
||||||
ok = true
|
ok = true
|
||||||
else
|
else
|
||||||
|
@ -119,7 +119,7 @@ function M.build(task)
|
||||||
"",
|
"",
|
||||||
"This plugin requires `luarocks`. Try one of the following:",
|
"This plugin requires `luarocks`. Try one of the following:",
|
||||||
" - fix your `luarocks` installation",
|
" - fix your `luarocks` installation",
|
||||||
Config.options.rocks.hererocks and " - disable *hererocks* with `opts.rocks.hererocks = false`"
|
Config.hererocks() and " - disable *hererocks* with `opts.rocks.hererocks = false`"
|
||||||
or " - enable `hererocks` with `opts.rocks.hererocks = true`",
|
or " - enable `hererocks` with `opts.rocks.hererocks = true`",
|
||||||
" - disable `luarocks` support completely with `opts.rocks.enabled = false`",
|
" - disable `luarocks` support completely with `opts.rocks.enabled = false`",
|
||||||
})
|
})
|
||||||
|
@ -132,7 +132,7 @@ function M.build(task)
|
||||||
|
|
||||||
local env = {}
|
local env = {}
|
||||||
local luarocks = "luarocks"
|
local luarocks = "luarocks"
|
||||||
if Config.options.rocks.hererocks then
|
if Config.hererocks() then
|
||||||
-- hererocks is still building, so skip for now
|
-- hererocks is still building, so skip for now
|
||||||
-- a new build will happen in the next round
|
-- a new build will happen in the next round
|
||||||
if M.hererocks.building() then
|
if M.hererocks.building() then
|
||||||
|
|
Loading…
Reference in New Issue