diff --git a/lua/dep/lazy/loader/init.lua b/lua/dep/lazy/loader/init.lua index 7569b9b..5918ef9 100644 --- a/lua/dep/lazy/loader/init.lua +++ b/lua/dep/lazy/loader/init.lua @@ -33,7 +33,21 @@ end ---@param opts vim.api.keyset.user_command? options function lazy_loader:cmd(name, opts) 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() end, opts)