Skip to content

Commit 4203cd8

Browse files
committed
remove redundant callback when using packadd
1 parent 27be65b commit 4203cd8

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lua/strive/init.lua

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ local function load_opts(opt)
654654
end
655655

656656
-- Load a plugin and its dependencies
657-
function Plugin:load(opts)
657+
function Plugin:load()
658658
if self.loaded then
659659
return true
660660
end
@@ -683,12 +683,12 @@ function Plugin:load(opts)
683683
if isdir(after_path) then
684684
vim.opt.rtp:append(after_path)
685685
end
686+
self:load_scripts()
686687
elseif self.is_lazy then
687688
-- For non-local lazy plugins, use packadd
688689
vim.cmd.packadd(self.plugin_name)
689690
end
690691

691-
self:load_scripts((opts and opts.script_cb) and opts.script_cb or nil)
692692
self:call_setup()
693693

694694
self.status = STATUS.LOADED
@@ -848,17 +848,15 @@ function Plugin:cmd(commands)
848848
pcall(api.nvim_del_user_command, cmd_name)
849849
local args = cmd_args.args ~= '' and ' ' .. cmd_args.args or ''
850850
local bang = cmd_args.bang and '!' or ''
851-
self:load({
852-
script_cb = function()
853-
if vim.fn.exists(':' .. cmd_name) == 2 then
854-
---@diagnostic disable-next-line: param-type-mismatch
855-
local ok, err = pcall(vim.cmd, cmd_name .. bang .. args)
856-
if not ok then
857-
vim.notify(string.format('execute %s wrong: %s', cmd_name, err), vim.log.levels.ERROR)
858-
end
859-
end
860-
end,
861-
})
851+
self:load()
852+
853+
if vim.fn.exists(':' .. cmd_name) == 2 then
854+
---@diagnostic disable-next-line: param-type-mismatch
855+
local ok, err = pcall(vim.cmd, cmd_name .. bang .. args)
856+
if not ok then
857+
vim.notify(string.format('execute %s wrong: %s', cmd_name, err), vim.log.levels.ERROR)
858+
end
859+
end
862860
end, {
863861
nargs = '*',
864862
bang = true,

0 commit comments

Comments
 (0)