improve lazy loading on commands, dep will now load on completion
This commit is contained in:
@ -33,7 +33,21 @@ end
|
|||||||
---@param opts vim.api.keyset.user_command? options
|
---@param opts vim.api.keyset.user_command? options
|
||||||
function lazy_loader:cmd(name, opts)
|
function lazy_loader:cmd(name, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
vim.api.nvim_create_user_command(name, opts['callback'] or function()
|
|
||||||
|
-- load the plugin on completion
|
||||||
|
if not opts["complete"] then
|
||||||
|
opts["complete"] = function(_, line, _)
|
||||||
|
self:cleanup()
|
||||||
|
|
||||||
|
-- return all completions for the current input, we need this to ensure
|
||||||
|
-- that the new completions are loaded from the actual plugin, not our
|
||||||
|
-- definiton of the command
|
||||||
|
return vim.fn.getcompletion(line, "cmdline")
|
||||||
|
end
|
||||||
|
opts["nargs"] = "*"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command(name, opts['callback'] or function(_)
|
||||||
self:cleanup()
|
self:cleanup()
|
||||||
end, opts)
|
end, opts)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user