Skip to content
This repository was archived by the owner on Dec 7, 2025. It is now read-only.

Commit 17ae5c2

Browse files
committed
update
1 parent 6f9c563 commit 17ae5c2

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

lua/strive/init.lua

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- A lightweight, feature-rich plugin manager with support for lazy loading,
33
-- dependencies, and asynchronous operations.
44

5-
local api, uv, if_nil, Iter = vim.api, vim.uv, vim.F.if_nil, vim.iter
5+
local api, uv, if_nil, Iter, ffi = vim.api, vim.uv, vim.F.if_nil, vim.iter, require('ffi')
66

77
-- =====================================================================
88
-- 1. Configuration and Constants
@@ -18,9 +18,8 @@ local OPT_DIR = vim.fs.joinpath(data_dir, 'site', 'pack', 'strive', 'opt')
1818

1919
-- Add to packpath
2020
vim.opt.packpath:prepend(vim.fs.joinpath(data_dir, 'site'))
21-
vim.g.pm_loaded = 0
21+
vim.g.strim_loaded = 0
2222

23-
-- Default settings
2423
local DEFAULT_SETTINGS = {
2524
max_concurrent_tasks = if_nil(vim.g.strive_max_concurrent_tasks, 5),
2625
auto_install = if_nil(vim.g.strive_auto_install, true),
@@ -653,7 +652,7 @@ function Plugin:load()
653652
-- Prevent recursive loading
654653
-- Set loaded to true before actual loading to prevent infinite loops
655654
self.loaded = true
656-
vim.g.pm_loaded = vim.g.pm_loaded + 1
655+
vim.g.strim_loaded = vim.g.strim_loaded + 1
657656

658657
Iter(self.dependencies):map(function(d)
659658
if not d.loaded then
@@ -695,7 +694,7 @@ function Plugin:on(events)
695694
once = true,
696695
callback = function(args)
697696
-- Don't re-emit the event if we've already loaded the plugin
698-
if not self.loaded and self:load() then
697+
if not self.loaded and self:load() and args.event == 'FileType' then
699698
-- We need to re-emit the event, but carefully to avoid nesting too deep
700699
-- Instead of exec_autocmds, trigger the event using a different mechanism
701700
local event_data = args.data and vim.deepcopy(args.data) or {}
@@ -1485,4 +1484,28 @@ if DEFAULT_SETTINGS.auto_install then
14851484
end
14861485

14871486
create_commands()
1487+
1488+
ffi.cdef([[
1489+
typedef long time_t;
1490+
typedef int clockid_t;
1491+
typedef struct timespec {
1492+
time_t tv_sec;
1493+
long tv_nsec;
1494+
} timespec;
1495+
int clock_gettime(clockid_t clk_id, struct timespec *tp);
1496+
]])
1497+
local CLOCK_PROCESS_CPUTIME_ID = vim.uv.os_uname().sysname:match('Darwin') and 12 or 2
1498+
1499+
api.nvim_create_autocmd('UIEnter', {
1500+
callback = function()
1501+
if vim.g.strive_startup_time ~= nil then
1502+
return
1503+
end
1504+
1505+
local t = assert(ffi.new('timespec[?]', 1))
1506+
ffi.C.clock_gettime(CLOCK_PROCESS_CPUTIME_ID, t)
1507+
vim.g.strive_startup_time = tonumber(t[0].tv_sec) * 1e3 + tonumber(t[0].tv_nsec) / 1e6
1508+
end,
1509+
})
1510+
14881511
return { use = M.use }

0 commit comments

Comments
 (0)