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

Commit 9afa145

Browse files
committed
update
1 parent 4e52830 commit 9afa145

File tree

1 file changed

+42
-47
lines changed

1 file changed

+42
-47
lines changed

lua/strive/init.lua

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -654,20 +654,20 @@ function Plugin:load()
654654
self.loaded = true
655655
vim.g.strim_loaded = vim.g.strim_loaded + 1
656656

657-
Iter(self.dependencies):map(function(d)
658-
if not d.loaded then
659-
d:load()
660-
end
661-
end)
662-
663657
load_opts(self.init_opts)
664658

665659
self:packadd()
660+
self:load_scripts()
666661

667662
self:call_setup()
668663

669-
load_opts(self.config_opts)
664+
Iter(self.dependencies):map(function(d)
665+
if not d.loaded then
666+
d:load()
667+
end
668+
end)
670669

670+
load_opts(self.config_opts)
671671
-- Update status
672672
self.status = STATUS.LOADED
673673

@@ -737,6 +737,33 @@ function Plugin:ft(filetypes)
737737
return self
738738
end
739739

740+
function Plugin:load_scripts()
741+
Async.async(function()
742+
local plugin_path = self:get_path()
743+
local plugin_dir = vim.fs.joinpath(plugin_path, 'plugin')
744+
745+
local handle = uv.fs_scandir(plugin_dir)
746+
if not handle then
747+
return
748+
end
749+
750+
while true do
751+
local name, type = uv.fs_scandir_next(handle)
752+
if not name then
753+
break
754+
end
755+
756+
if type == 'file' and (name:match('%.lua$') or name:match('%.vim$')) then
757+
local file_path = vim.fs.joinpath(plugin_dir, name)
758+
759+
vim.schedule(function()
760+
vim.cmd('source ' .. vim.fn.fnameescape(file_path))
761+
end)
762+
end
763+
end
764+
end)()
765+
end
766+
740767
-- Set up lazy loading for specific commands
741768
function Plugin:cmd(commands)
742769
self.is_lazy = true
@@ -747,46 +774,16 @@ function Plugin:cmd(commands)
747774
pcall(api.nvim_del_user_command, cmd_name)
748775
local args = cmd_args.args ~= '' and ' ' .. cmd_args.args or ''
749776
local bang = cmd_args.bang and '!' or ''
750-
Async.async(function()
751-
if not self.loaded then
752-
self:load()
753-
754-
local plugin_path = self:get_path()
755-
local plugin_dir = vim.fs.joinpath(plugin_path, 'plugin')
756-
757-
local stat = uv.fs_stat(plugin_dir)
758-
if stat and stat.type == 'directory' then
759-
local handle = uv.fs_scandir(plugin_dir)
760-
if handle then
761-
while true do
762-
local name, type = uv.fs_scandir_next(handle)
763-
if not name then
764-
break
765-
end
766-
767-
if type == 'file' and (name:match('%.lua$') or name:match('%.vim$')) then
768-
local file_path = vim.fs.joinpath(plugin_dir, name)
769-
vim.schedule(function()
770-
vim.cmd('source ' .. vim.fn.fnameescape(file_path))
771-
end)
772-
end
773-
end
774-
end
777+
self:load()
778+
vim.schedule(function()
779+
if vim.fn.exists(':' .. cmd_name) == 2 then
780+
---@diagnostic disable-next-line: param-type-mismatch
781+
local ok, err = pcall(vim.cmd, cmd_name .. bang .. args)
782+
if not ok then
783+
vim.notify(string.format('execute %s wrong: %s', cmd_name, err), vim.log.levels.ERROR)
775784
end
776-
777-
vim.schedule(function()
778-
if vim.fn.exists(':' .. cmd_name) == 2 then
779-
local ok, err = pcall(vim.cmd, cmd_name .. bang .. args)
780-
if not ok then
781-
vim.notify(
782-
string.format('execute %s wrong: %s', cmd_name, err),
783-
vim.log.levels.ERROR
784-
)
785-
end
786-
end
787-
end)
788785
end
789-
end)()
786+
end)
790787
end, {
791788
nargs = '*',
792789
bang = true,
@@ -1204,8 +1201,6 @@ function M.log(level, message)
12041201
end
12051202
end
12061203

1207-
local called_installer = false
1208-
12091204
-- Register a plugin
12101205
function M.use(spec)
12111206
local plugin = Plugin.new(spec)

0 commit comments

Comments
 (0)