From b16d22578680b5d27897e07e560dd12ec5eb5fb6 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Wed, 10 Sep 2025 20:42:53 +0800 Subject: [PATCH] feat: support puc lua --- lua/lazy/core/config.lua | 2 +- lua/lazy/core/util.lua | 2 +- lua/lazy/init.lua | 3 --- lua/lazy/stats.lua | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 603dd1a..6263b7d 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -23,7 +23,7 @@ M.defaults = { local_spec = true, -- load project specific .lazy.lua spec files. They will be added at the end of the spec. lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update. ---@type number? limit the maximum amount of concurrent tasks - concurrency = jit.os:find("Windows") and (vim.uv.available_parallelism() * 2) or nil, + concurrency = (vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1) and (vim.uv.available_parallelism() * 2) or nil, git = { -- defaults for the `Lazy log` command -- log = { "--since=3 days ago" }, -- show commits from the last 3 days diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index 83e8a92..d87d0ed 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -5,7 +5,7 @@ local M = {} ---@type LazyProfile[] M._profiles = { { name = "lazy" } } -M.is_win = jit.os:find("Windows") +M.is_win = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 ---@param data (string|{[string]:string})? ---@param time number? diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua index 4336da1..7f0d0ec 100644 --- a/lua/lazy/init.lua +++ b/lua/lazy/init.lua @@ -52,9 +52,6 @@ function M.setup(spec, opts) if vim.fn.has("nvim-0.8.0") ~= 1 then return vim.notify("lazy.nvim requires Neovim >= 0.8.0", vim.log.levels.ERROR, { title = "lazy.nvim" }) end - if not (pcall(require, "ffi") and jit and jit.version) then - return vim.notify("lazy.nvim requires Neovim built with LuaJIT", vim.log.levels.ERROR, { title = "lazy.nvim" }) - end local start = vim.uv.hrtime() -- use the Neovim cache if available diff --git a/lua/lazy/stats.lua b/lua/lazy/stats.lua index 015a2be..df420df 100644 --- a/lua/lazy/stats.lua +++ b/lua/lazy/stats.lua @@ -1,5 +1,3 @@ -local ffi = require("ffi") - local M = {} ---@class LazyStats @@ -34,6 +32,7 @@ end function M.cputime() if M.C == nil then pcall(function() + local ffi = require("ffi") ffi.cdef([[ typedef long time_t; typedef int clockid_t; @@ -48,6 +47,7 @@ function M.cputime() end local function real() + local ffi = require("ffi") local pnano = assert(ffi.new("nanotime[?]", 1)) local CLOCK_PROCESS_CPUTIME_ID = jit.os == "OSX" and 12 or 2 ffi.C.clock_gettime(CLOCK_PROCESS_CPUTIME_ID, pnano)