Skip to content

refactor!: :ZPack with subcommands#21

Closed
yavorski wants to merge 0 commit into
zuqini:mainfrom
yavorski:main
Closed

refactor!: :ZPack with subcommands#21
yavorski wants to merge 0 commit into
zuqini:mainfrom
yavorski:main

Conversation

@yavorski

@yavorski yavorski commented May 16, 2026

Copy link
Copy Markdown
Contributor

Replace the prefixed commands :ZUpdate, :ZRestore, :ZClean, :ZBuild, :ZLoad, :ZDelete with a single :ZPack command that dispatches to update, restore, clean, build, load, and delete subcommands.

Bang and plugin-name args carry over (e.g. :ZPack! load alpha), and subcommand + plugin-name tab completion works at both levels.

The cmd_prefix setup option is replaced by cmd_name (default ZPack). The old option is registered in deprecation.removed and shows a migration warning if setup.

BREAKING CHANGE: cmd_prefix no longer has any effect; use the new cmd_name instead.

image

More info on best practices: https://github.com/lumen-oss/nvim-best-practices#speaking_head-user-commands


You can try it directly from my fork

@zuqini zuqini left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution, and the link to best practices. I agree this is a better approach going forward!

For a smoother migration experience, I think we should keep cmd_prefix working during the deprecation period — keep registering the prefixed commands (:ZUpdate, :ZClean, …) alongside the new :ZPack interface instead of removing them outright.

The other deprecated options (confirm, disable_vim_loader, plugins_dir) all keep functioning while emitting a warning, so I'd suggest moving cmd_prefix into deprecation.deprecated and doing the same here. The new Sub table already isolates each subcommand's logic, so the legacy commands should just be a small registration shim on top of it — I think a bit of temporary code is a fair trade for not breaking existing setups.

One thing to watch on the warning itself: cmd_prefix defaulted to 'Z', so most users never set it explicitly — a setup-time warning keyed on the option being passed would miss them entirely. I'd suggest emitting the deprecation notice when a legacy command is actually invoked (once, deduped), so it reaches everyone still on the old commands.

Could we also extend the new deprecation test to assert the legacy commands are still created and that invoking one emits the warning?

@yavorski

Copy link
Copy Markdown
Contributor Author

Ok, Sounds good.
I will apply them when I get to my PC.

@yavorski yavorski force-pushed the main branch 4 times, most recently from e3b9fae to c3fb251 Compare May 17, 2026 15:33
@yavorski yavorski closed this May 17, 2026
zuqini added a commit that referenced this pull request May 17, 2026
Non-blocking issues surfaced while reviewing the :ZPack subcommand
refactor and its cmd_prefix deprecation shim.

commands.lua:
- complete_command strips the command word explicitly, so a bang-attached
  subcommand (:ZPack!load) no longer mis-parses and offers subcommand names
  at the plugin-name position
- the dispatcher rejects a bang on subcommands that ignore it
  (update/restore/clean), restoring the feedback the old :ZUpdate! E477 gave
- the dispatcher rejects extra positional args instead of joining them into
  a misleading 'Plugin "a b" not found in spec' error
- validate_name type-checks its input, so a non-string cmd_prefix/cmd_name
  no longer throws and aborts setup()
- setup_legacy threads the resolved cmd_name into legacy command descs and
  warnings instead of hardcoding :ZPack
- setup_legacy emits an error notice for an invalid cmd_prefix instead of
  returning silently
- a startup assert keeps SUB_ORDER in sync with the Sub table
- the cmd_prefix deprecation warning dedups once total, not once per command

tests:
- repurpose cmd_prefix_test.lua as an explicit legacy-shim test: rename the
  describe block, assert the deprecation warning fires, drop the rejection
  cases duplicated by cmd_name_test.lua, and fix delete_zpack_commands
  cleanup calls that passed the prefix as the cmd_name positional
- add dispatch_test.lua covering the bang/extra-arg/completion fixes
- deprecation_test asserts the warning dedups across different legacy commands
- drop the :ZPack-creation test duplicated from cmd_name_test.lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants