From 30de216bbbe50b4c4a477f35baafc13adacff256 Mon Sep 17 00:00:00 2001 From: zuqini Date: Mon, 18 May 2026 22:29:37 -0700 Subject: [PATCH] feat!: remove deprecated features for 2.0.0 Remove every deprecated and already-removed feature ahead of the 2.0.0 release, along with the supporting deprecation infrastructure: - opts.confirm -> defaults.confirm - opts.disable_vim_loader -> performance.vim_loader - opts.plugins_dir -> { import = 'dir' } in spec - opts.cmd_prefix and the legacy :Z* commands -> :ZPack - opts.auto_import (already a no-op; notice dropped) - zpack.add() (already a no-op; function dropped) With nothing left to notify, zpack.deprecation is now unused and is deleted, state.deprecations is removed, and :checkhealth zpack no longer reports deprecated options. BREAKING CHANGE: the options and commands listed above no longer work. Migrate to the replacements shown before upgrading to 2.0.0. --- doc/zpack.txt | 4 +- lua/zpack/commands.lua | 53 ----------- lua/zpack/deprecation.lua | 103 --------------------- lua/zpack/health.lua | 30 +------ lua/zpack/init.lua | 46 +--------- lua/zpack/state.lua | 5 -- lua/zpack/validate.lua | 15 ++-- tests/cmd_prefix_test.lua | 180 ------------------------------------- tests/deprecation_test.lua | 105 ---------------------- tests/health_test.lua | 15 ---- tests/helpers.lua | 8 +- tests/setup_test.lua | 17 ---- tests/validate_test.lua | 10 +-- 13 files changed, 11 insertions(+), 580 deletions(-) delete mode 100644 lua/zpack/deprecation.lua delete mode 100644 tests/cmd_prefix_test.lua delete mode 100644 tests/deprecation_test.lua diff --git a/doc/zpack.txt b/doc/zpack.txt index 3296e65..1b0f0da 100644 --- a/doc/zpack.txt +++ b/doc/zpack.txt @@ -290,9 +290,7 @@ Environment Confirms Neovim is 0.12.0+ and that `vim.pack` is available. Setup Whether |zpack.setup()| has been called. zpack is inactive until it has. -Configuration Validates the resolved |zpack-setup-options| and lists any - deprecated or removed options still in use, with their - replacements. +Configuration Validates the resolved |zpack-setup-options|. Plugins A status summary of every registered plugin: how many are loaded, lazy, pending, installing, or disabled by `cond`. diff --git a/lua/zpack/commands.lua b/lua/zpack/commands.lua index 081e706..582d28d 100644 --- a/lua/zpack/commands.lua +++ b/lua/zpack/commands.lua @@ -520,57 +520,4 @@ M.setup = function(cmd_name) end end ---------------------------------------------------------------------- --- Legacy commands ---------------------------------------------------------------------- - --- Command suffixes frozen from the pre-:ZPack era; new subcommands --- intentionally do not get legacy aliases. Each legacy command delegates --- to the : dispatcher, so bang/argument validation cannot drift --- from it. -local LEGACY_SUFFIXES = { 'Update', 'Restore', 'Clean', 'Build', 'Load', 'Delete' } - ----@param prefix string Prefix to register legacy commands under (e.g. 'Z'). Empty string registers bare :Update/:Clean/etc. ----@param cmd_name string Resolved primary command name, referenced in deprecation messages. -M.setup_legacy = function(prefix, cmd_name) - local deprecation = require('zpack.deprecation') - - -- Empty prefix is a valid back-compat case; otherwise enforce the same rules as cmd_name. - if prefix ~= '' and not validate_name(prefix) then - deprecation.notify_cmd_prefix_deprecated(cmd_name) - util.schedule_notify( - ('Invalid cmd_prefix "%s": must start with uppercase letter and contain only letters/digits. Legacy commands not registered.') - :format(tostring(prefix)), - vim.log.levels.ERROR - ) - return - end - - local dispatch = make_dispatcher(cmd_name) - - for _, suffix in ipairs(LEGACY_SUFFIXES) do - local legacy_name = prefix .. suffix - local sub_name = suffix:lower() - local sub = Sub[sub_name] - -- Registered permissively (nargs '*', bang) so any misuse reaches the - -- dispatcher and gets its validation rather than a raw Vim parse error. - local cmd_opts = { - nargs = '*', - bang = true, - desc = ('[deprecated] use :%s %s instead'):format(cmd_name, sub_name), - } - - if sub.complete then - cmd_opts.complete = function(arg_lead) return sub.complete(arg_lead) end - end - - pcall(vim.api.nvim_create_user_command, legacy_name, function(opts) - deprecation.notify_legacy_command(legacy_name, cmd_name, sub_name) - local dispatch_args = { sub_name } - vim.list_extend(dispatch_args, opts.fargs) - dispatch({ fargs = dispatch_args, bang = opts.bang }) - end, cmd_opts) - end -end - return M diff --git a/lua/zpack/deprecation.lua b/lua/zpack/deprecation.lua deleted file mode 100644 index f828dbb..0000000 --- a/lua/zpack/deprecation.lua +++ /dev/null @@ -1,103 +0,0 @@ --- Deprecation and removal notices for zpack. --- --- This custom layer is kept deliberately rather than migrated to --- vim.deprecate(); the evaluation: --- * Legacy : commands notify on EVERY invocation (see --- notify_legacy_command) so a notice that scrolled past is not lost. --- vim.deprecate() routes through vim.notify_once and would dedup it, --- conflicting with that intent. --- * `add`/`auto_import` are already removed, not pending removal, so --- vim.deprecate()'s "will be removed in version X" framing is wrong. --- * The option notices below carry copy-paste replacement snippets that --- vim.deprecate()'s single-line `alternative` argument cannot express. --- Deprecated options actually in use are also surfaced by :checkhealth zpack. - -local utils = require('zpack.utils') - -local M = {} - --- Every M.removed/M.deprecated entry must carry both `message` and --- `replacement` strings: notify_removed/notify_deprecated format them --- unguarded, and :checkhealth zpack splits `replacement` into advice lines. -M.removed = { - add = { - message = "zpack.add() has been removed. Pass specs directly to setup():", - replacement = [[ -require('zpack').setup({ { 'user/plugin' } }) -require('zpack').setup({ spec = { { 'user/plugin' } } }) -- or via the spec field -]] - }, - auto_import = { - message = "auto_import option has been removed. Pass specs directly to setup():", - replacement = [[ -require('zpack').setup({ { 'user/plugin' } }) -require('zpack').setup({ spec = { { 'user/plugin' } } }) -- or via the spec field -]] - }, -} - -M.deprecated = { - confirm = { - message = "opts.confirm is deprecated. Use opts.defaults.confirm instead:", - replacement = "require('zpack').setup({ defaults = { confirm = false } })", - }, - disable_vim_loader = { - message = "opts.disable_vim_loader is deprecated. Use opts.performance.vim_loader instead:", - replacement = "require('zpack').setup({ performance = { vim_loader = false } })", - }, - plugins_dir = { - message = "opts.plugins_dir is deprecated. Use { import = 'dir' } in spec instead:", - replacement = "require('zpack').setup({ { import = 'plugins' } })", - }, -} - --- setup() option keys that are deprecated or removed, for :checkhealth zpack --- to report when one is still passed. Kept here as the single authoritative --- list rather than derived from M.removed/M.deprecated: M.removed also holds --- `add` (a removed function, not an option key) and `cmd_prefix` has only --- computed notices with no static entry — so the key set is neither table's --- keys. Update this list whenever M.removed/M.deprecated gains an option. -M.deprecated_option_keys = { - 'cmd_prefix', 'confirm', 'disable_vim_loader', 'plugins_dir', 'auto_import', -} - -M.notify_removed = function(key) - local entry = M.removed[key] - if not entry then return end - utils.schedule_notify( - ("REMOVED: %s\n\n%s"):format(entry.message, entry.replacement), - vim.log.levels.WARN - ) -end - -M.notify_deprecated = function(key) - local entry = M.deprecated[key] - if not entry then return end - utils.schedule_notify( - ("DEPRECATED: %s\n\n%s"):format(entry.message, entry.replacement), - vim.log.levels.WARN - ) -end - --- Warns that a legacy : command is deprecated in favor of --- the : form. Fires on every invocation so the notice --- is not missed if an earlier one scrolled past. -M.notify_legacy_command = function(legacy_name, cmd_name, sub_name) - utils.schedule_notify( - ("DEPRECATED: :%s is deprecated. Use :%s %s instead."):format(legacy_name, cmd_name, sub_name), - vim.log.levels.WARN - ) -end - --- Computed because it must name the user's resolved cmd_name. Not deduped: --- the only caller is setup_legacy's invalid-prefix branch, which runs once. -M.notify_cmd_prefix_deprecated = function(cmd_name) - utils.schedule_notify( - ("DEPRECATED: opts.cmd_prefix is deprecated. The legacy prefixed commands are " - .. "deprecated aliases for the :%s subcommands; drop cmd_prefix and use " - .. ":%s instead."):format(cmd_name, cmd_name), - vim.log.levels.WARN - ) -end - -return M diff --git a/lua/zpack/health.lua b/lua/zpack/health.lua index f0f4cfe..899b872 100644 --- a/lua/zpack/health.lua +++ b/lua/zpack/health.lua @@ -2,8 +2,8 @@ --- ---Surfaces, in the editor, what a misconfigured setup otherwise only reveals ---as a runtime error: an unsupported Neovim version, a missing `vim.pack`, ----`setup()` never being called, malformed config, deprecated options still ----in use, or specs that never resolved. +---`setup()` never being called, malformed config, or specs that never +---resolved. --- ---Discovered automatically by `:checkhealth zpack` — nothing registers it. @@ -68,32 +68,6 @@ local function check_config() vim.health.error('Invalid option: ' .. err) end end - - if #state.deprecations == 0 then - vim.health.ok('No deprecated options in use') - else - local deprecation = require('zpack.deprecation') - -- A replacement snippet can span several lines; split it so each renders - -- as its own advice line instead of one bullet with embedded newlines. - local function advice(entry) - local lines = { entry.message } - vim.list_extend(lines, vim.split(entry.replacement, '\n', { trimempty = true })) - return lines - end - for _, key in ipairs(state.deprecations) do - local removed = deprecation.removed[key] - local deprecated = deprecation.deprecated[key] - if removed then - vim.health.warn(('Removed option still passed: %s'):format(key), advice(removed)) - elseif deprecated then - vim.health.warn(('Deprecated option in use: %s'):format(key), advice(deprecated)) - else - -- cmd_prefix is in deprecated_option_keys but has no static - -- removed/deprecated entry (its notice is computed) — warn bare. - vim.health.warn(('Deprecated option in use: %s'):format(key)) - end - end - end end local function check_plugins() diff --git a/lua/zpack/init.lua b/lua/zpack/init.lua index 2891bf6..5c50fe1 100644 --- a/lua/zpack/init.lua +++ b/lua/zpack/init.lua @@ -63,11 +63,6 @@ end ---@field performance? zpack.Config.Performance ---@field profiling? zpack.Config.Profiling ---@field dev? zpack.Config.Dev ----@field plugins_dir? string @deprecated Use { import = 'dir' } in spec instead ----@field confirm? boolean @deprecated Use defaults.confirm instead ----@field disable_vim_loader? boolean @deprecated Use performance.vim_loader instead ----@field cmd_prefix? string @deprecated Legacy : commands; use : ----@field auto_import? any @deprecated Removed; pass specs to setup() instead local config = { cmd_name = 'ZPack', @@ -128,17 +123,6 @@ M.setup = function(opts) state.is_setup = true - local deprecation = require('zpack.deprecation') - - -- Record deprecated/removed options for :checkhealth zpack. Assigned fresh - -- so the list reflects only this setup() call. - state.deprecations = {} - for _, key in ipairs(deprecation.deprecated_option_keys) do - if opts[key] ~= nil then - state.deprecations[#state.deprecations + 1] = key - end - end - if opts.cmd_name ~= nil then config.cmd_name = opts.cmd_name end @@ -159,18 +143,6 @@ M.setup = function(opts) config.dev = vim.tbl_extend('force', config.dev, opts.dev) end - -- Handle deprecated opts.confirm - if opts.confirm ~= nil then - deprecation.notify_deprecated('confirm') - config.defaults.confirm = opts.confirm - end - - -- Handle deprecated opts.disable_vim_loader - if opts.disable_vim_loader ~= nil then - deprecation.notify_deprecated('disable_vim_loader') - config.performance.vim_loader = not opts.disable_vim_loader - end - -- Expose the fully merged config so :checkhealth and other tooling can -- introspect it. Sections are flat one-level tables, so the `tbl_extend` -- merges above are sufficient (no `tbl_deep_extend` needed). This is the @@ -181,13 +153,6 @@ M.setup = function(opts) vim.loader.enable() end - if opts.auto_import ~= nil then - deprecation.notify_removed('auto_import') - end - - -- `cmd_prefix` is deprecated but will still work for a while - local legacy_prefix = opts.cmd_prefix ~= nil and opts.cmd_prefix or 'Z' - local ctx = create_context({ confirm = config.defaults.confirm, defaults = config.defaults }) local import = require('zpack.import') @@ -196,22 +161,13 @@ M.setup = function(opts) import.import_specs(spec, ctx) end - if type(opts.plugins_dir) == 'string' then - deprecation.notify_deprecated('plugins_dir') - import.import_specs({ import = opts.plugins_dir }, ctx) - elseif not spec then + if not spec then import.import_specs({ import = 'plugins' }, ctx) end process_all(ctx) require('zpack.commands').setup(config.cmd_name) - require('zpack.commands').setup_legacy(legacy_prefix, config.cmd_name) -end - ----@deprecated Use setup({ spec = { ... } }) instead -M.add = function() - require('zpack.deprecation').notify_removed('add') end ---Public API contract version. Alias for |zpack.api.VERSION|. diff --git a/lua/zpack/state.lua b/lua/zpack/state.lua index d28b82f..777ee38 100644 --- a/lua/zpack/state.lua +++ b/lua/zpack/state.lua @@ -8,11 +8,6 @@ M.is_setup = false ---@type zpack.Config? M.config = nil ----Names of deprecated/removed `setup()` options the user passed, recorded so ----`:checkhealth zpack` can report them. ----@type string[] -M.deprecations = {} - M.lazy_group = vim.api.nvim_create_augroup('LazyPack', { clear = true }) M.startup_group = vim.api.nvim_create_augroup('StartupPack', { clear = true }) M.lazy_build_group = vim.api.nvim_create_augroup('LazyBuildPack', { clear = true }) diff --git a/lua/zpack/validate.lua b/lua/zpack/validate.lua index 28bedc9..9531870 100644 --- a/lua/zpack/validate.lua +++ b/lua/zpack/validate.lua @@ -32,12 +32,12 @@ end ---Validates the raw `opts` (rather than the post-merge config) because the ---per-section `vim.tbl_extend('force', ...)` merges in `setup()` themselves ---throw when handed a non-table — validation has to run first. It is also ----safe to call on a merged `zpack.Config`: the legacy/`spec` fields are ----simply absent and pass as optional, which is how |zpack.health| reuses it. +---safe to call on a merged `zpack.Config`: the `spec` field is simply absent +---and passes as optional, which is how |zpack.health| reuses it. --- ----`cmd_name`/`cmd_prefix` are intentionally excluded: `zpack.commands` ----validates them (type *and* naming rule) and degrades gracefully, so ----re-checking here would only double up the notification. +---`cmd_name` is intentionally excluded: `zpack.commands` validates it (type +---*and* naming rule) and degrades gracefully, so re-checking here would only +---double up the notification. ---@param opts any The table passed to `zpack.setup()` ---@return string[] errors Field-path messages; empty when valid function M.validate_config(opts) @@ -72,11 +72,6 @@ function M.validate_config(opts) check(errors, 'profiling.require', opts.profiling.require, 'boolean') end - -- Legacy options: deprecated but still honored, so still type-checked. - check(errors, 'confirm', opts.confirm, 'boolean') - check(errors, 'disable_vim_loader', opts.disable_vim_loader, 'boolean') - check(errors, 'plugins_dir', opts.plugins_dir, 'string') - return errors end diff --git a/tests/cmd_prefix_test.lua b/tests/cmd_prefix_test.lua deleted file mode 100644 index 3b04f20..0000000 --- a/tests/cmd_prefix_test.lua +++ /dev/null @@ -1,180 +0,0 @@ -local helpers = require('helpers') - -describe("Legacy cmd_prefix Commands (deprecated)", function() - before_each(helpers.setup_test_env) - after_each(helpers.cleanup_test_env) - - it("default prefix registers Z-prefixed legacy commands", function() - require('zpack').setup({ spec = {}, defaults = { confirm = false } }) - - local cmds = vim.api.nvim_get_commands({}) - assert.is_not_nil(cmds['ZUpdate'], "ZUpdate command should exist") - assert.is_not_nil(cmds['ZRestore'], "ZRestore command should exist") - assert.is_not_nil(cmds['ZClean'], "ZClean command should exist") - assert.is_not_nil(cmds['ZBuild'], "ZBuild command should exist") - assert.is_not_nil(cmds['ZLoad'], "ZLoad command should exist") - assert.is_not_nil(cmds['ZDelete'], "ZDelete command should exist") - end) - - it("custom cmd_prefix registers prefixed legacy commands", function() - require('zpack').setup({ spec = {}, defaults = { confirm = false }, cmd_prefix = 'Pack' }) - - local cmds = vim.api.nvim_get_commands({}) - assert.is_not_nil(cmds['PackUpdate'], "PackUpdate command should exist") - assert.is_not_nil(cmds['PackDelete'], "PackDelete command should exist") - assert.is_nil(cmds['ZUpdate'], "default ZUpdate should not exist with a custom prefix") - helpers.delete_zpack_commands(nil, 'Pack') - end) - - it("empty cmd_prefix registers bare legacy commands", function() - require('zpack').setup({ spec = {}, defaults = { confirm = false }, cmd_prefix = '' }) - - local cmds = vim.api.nvim_get_commands({}) - assert.is_not_nil(cmds['Update'], "Update command should exist") - assert.is_not_nil(cmds['Delete'], "Delete command should exist") - helpers.delete_zpack_commands(nil, '') - end) - - it("cmd_prefix with digits after the first letter is valid", function() - require('zpack').setup({ spec = {}, defaults = { confirm = false }, cmd_prefix = 'Z2' }) - - local cmds = vim.api.nvim_get_commands({}) - assert.is_not_nil(cmds['Z2Update'], "Z2Update command should exist") - assert.is_not_nil(cmds['Z2Delete'], "Z2Delete command should exist") - helpers.delete_zpack_commands(nil, 'Z2') - end) - - it("invoking a legacy command warns with its :ZPack replacement", function() - require('zpack').setup({ spec = { { 'test/plugin-a' } }, defaults = { confirm = false } }) - - helpers.flush_pending() - _G.test_state.notifications = {} - - vim.cmd('ZClean') - helpers.flush_pending() - - local found = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find(":ZClean is deprecated", 1, true) - and notif.msg:find("Use :ZPack clean", 1, true) then - found = true - break - end - end - assert.is_truthy(found, "invoking :ZClean should warn to use :ZPack clean") - end) - - it("legacy commands reference the configured cmd_name", function() - require('zpack').setup({ spec = {}, defaults = { confirm = false }, cmd_name = 'MyPack' }) - - helpers.flush_pending() - _G.test_state.notifications = {} - - vim.cmd('ZLoad') -- no bang, no arg -> warns "Use :! load" - helpers.flush_pending() - - local found = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find(':MyPack! load', 1, true) then - found = true - break - end - end - assert.is_truthy(found, "legacy :ZLoad should point at the configured :MyPack command") - helpers.delete_zpack_commands('MyPack') - end) - - it("legacy command with extra arguments warns like the dispatcher", function() - require('zpack').setup({ spec = { { 'test/plugin-a' } }, defaults = { confirm = false } }) - - helpers.flush_pending() - _G.test_state.notifications = {} - - vim.cmd('ZUpdate plugin-a extra-arg') - helpers.flush_pending() - - assert.are.equal(0, #_G.test_state.vim_pack_update_calls) - - local found_warning = false - local misleading_error = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find('at most one argument') and notif.level == vim.log.levels.WARN then - found_warning = true - end - if notif.msg:find('not found in spec') then - misleading_error = true - end - end - assert.is_truthy(found_warning, "legacy :ZUpdate should warn about too many arguments") - assert.is_falsy(misleading_error, 'legacy :ZUpdate must not emit the misleading joined-args error') - end) - - it("legacy clean rejects positional arguments without a raw Vim error", function() - require('zpack').setup({ spec = { { 'test/plugin-a' } }, defaults = { confirm = false } }) - - helpers.flush_pending() - _G.test_state.notifications = {} - - local ok = pcall(vim.cmd, 'ZClean junk') - helpers.flush_pending() - - assert.is_truthy(ok, "legacy :ZClean junk must not raise a raw Vim parse error") - - local found_warning = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find('no arguments') and notif.level == vim.log.levels.WARN then - found_warning = true - break - end - end - assert.is_truthy(found_warning, "legacy :ZClean should warn that clean accepts no arguments") - end) - - it("invalid cmd_prefix emits an error plus a deprecation notice and registers no legacy commands", function() - require('zpack').setup({ spec = {}, defaults = { confirm = false }, cmd_prefix = 'My-Pack' }) - - helpers.flush_pending() - - local cmds = vim.api.nvim_get_commands({}) - assert.is_nil(cmds['My-PackUpdate'], "no legacy commands should be registered for an invalid prefix") - assert.is_nil(cmds['ZUpdate'], "an invalid prefix should not fall back to the default Z prefix") - assert.is_not_nil(cmds['ZPack'], "the primary :ZPack command should still be registered") - - local found_error = false - local found_deprecation = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find('Invalid cmd_prefix') and notif.level == vim.log.levels.ERROR then - found_error = true - end - if notif.msg:find('DEPRECATED') and notif.msg:find('cmd_prefix', 1, true) - and notif.level == vim.log.levels.WARN then - found_deprecation = true - end - end - assert.is_truthy(found_error, "an invalid cmd_prefix should emit an error notification") - assert.is_truthy(found_deprecation, "an invalid cmd_prefix should also emit the cmd_prefix deprecation notice") - end) - - it("non-string cmd_prefix does not abort setup", function() - local ok = pcall(require('zpack').setup, { - spec = {}, - defaults = { confirm = false }, - cmd_prefix = {}, - }) - assert.is_truthy(ok, "setup() must not abort when cmd_prefix is not a string") - - helpers.flush_pending() - - local cmds = vim.api.nvim_get_commands({}) - assert.is_not_nil(cmds['ZPack'], "the primary :ZPack command should still be registered") - - local found_error = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find('Invalid cmd_prefix') and notif.level == vim.log.levels.ERROR then - found_error = true - break - end - end - assert.is_truthy(found_error, "a non-string cmd_prefix should emit an error notification") - end) -end) diff --git a/tests/deprecation_test.lua b/tests/deprecation_test.lua deleted file mode 100644 index e6a62df..0000000 --- a/tests/deprecation_test.lua +++ /dev/null @@ -1,105 +0,0 @@ -local helpers = require('helpers') - -describe("Deprecated Options", function() - before_each(helpers.setup_test_env) - after_each(helpers.cleanup_test_env) - - it("deprecated confirm option shows warning", function() - require('zpack').setup({ spec = {}, confirm = false }) - - helpers.flush_pending() - - local found_deprecation = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find("DEPRECATED") and notif.msg:find("confirm") then - found_deprecation = true - break - end - end - - assert.is_truthy(found_deprecation, "Should show deprecation warning for confirm") - end) - - it("deprecated disable_vim_loader option shows warning", function() - require('zpack').setup({ spec = {}, disable_vim_loader = true }) - - helpers.flush_pending() - - local found_deprecation = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find("DEPRECATED") and notif.msg:find("disable_vim_loader") then - found_deprecation = true - break - end - end - - assert.is_truthy(found_deprecation, "Should show deprecation warning for disable_vim_loader") - end) - - it("deprecated plugins_dir option shows warning", function() - require('zpack').setup({ plugins_dir = 'my_plugins' }) - - helpers.flush_pending() - - local found_deprecation = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find("DEPRECATED") and notif.msg:find("plugins_dir") then - found_deprecation = true - break - end - end - - assert.is_truthy(found_deprecation, "Should show deprecation warning for plugins_dir") - end) - - it("invoking legacy :Z* commands emits the deprecation warning every time", function() - require('zpack').setup({ spec = { { 'test/plugin-a' } }, defaults = { confirm = false } }) - - helpers.flush_pending() - _G.test_state.notifications = {} - - vim.cmd('ZClean') - vim.cmd('ZClean') -- repeated use must re-emit the warning - vim.cmd('ZUpdate') - helpers.flush_pending() - - local count = 0 - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find("DEPRECATED") and notif.msg:find("Use :ZPack") then - count = count + 1 - end - end - assert.are.equal(3, count) - end) - - it("legacy :ZDelete delegates to the new delete subcommand with force=true", function() - require('zpack').setup({ - spec = { { 'test/plugin-a' }, { 'test/plugin-b' } }, - defaults = { confirm = false }, - }) - - helpers.flush_pending() - - vim.cmd('ZDelete plugin-a') - helpers.flush_pending() - - assert.are.equal(1, #_G.test_state.vim_pack_del_calls) - local call = _G.test_state.vim_pack_del_calls[1] - assert.is_truthy(call.opts.force, "legacy :ZDelete must propagate force=true to Sub.delete") - assert.contains(call.names, 'plugin-a') - end) - - it("deprecated options still register plugins", function() - local state = require('zpack.state') - - require('zpack').setup({ - spec = { { 'test/plugin' } }, - confirm = false, - }) - - helpers.flush_pending() - - local src = 'https://github.com/test/plugin' - assert.is_not_nil(state.spec_registry[src], "Plugin should be registered") - end) -end) diff --git a/tests/health_test.lua b/tests/health_test.lua index e44b76e..2728013 100644 --- a/tests/health_test.lua +++ b/tests/health_test.lua @@ -109,27 +109,12 @@ describe("Health Check", function() local config = section(report, 'Configuration') assert.is_truthy(has_item(config, 'ok', { 'valid' }), "Configuration should be valid") - assert.is_truthy(has_item(config, 'ok', { 'No deprecated options' }), - "no deprecated options should be reported") local plugins = section(report, 'Plugins') assert.is_truthy(has_item(plugins, 'ok', { 'plugin(s) registered' }), "Plugins section should report a registered count") end) - it("surfaces deprecated options in use", function() - require('zpack').setup({ spec = {}, confirm = false }) - helpers.flush_pending() - - local report, restore = capture_health() - run_check() - restore() - - local config = section(report, 'Configuration') - assert.is_truthy(has_item(config, 'warn', { 'confirm' }), - "Configuration section should warn about the deprecated confirm option") - end) - it("surfaces an invalid merged config", function() require('zpack').setup({ spec = {}, defaults = { confirm = 'yes' } }) helpers.flush_pending() diff --git a/tests/helpers.lua b/tests/helpers.lua index 77f750c..c1036d1 100644 --- a/tests/helpers.lua +++ b/tests/helpers.lua @@ -183,7 +183,6 @@ function M.cleanup_test_env() package.loaded['zpack.keymap'] = nil package.loaded['zpack.utils'] = nil package.loaded['zpack.commands'] = nil - package.loaded['zpack.deprecation'] = nil package.loaded['zpack.merge'] = nil package.loaded['zpack.module_loader'] = nil package.loaded['zpack.api'] = nil @@ -260,14 +259,9 @@ function M.cleanup_mock_plugin_dir(base_path) end ---@param cmd_name? string Primary command name registered by `setup` (default 'ZPack'). ----@param legacy_prefix? string Prefix for the deprecated : commands (default 'Z'). -function M.delete_zpack_commands(cmd_name, legacy_prefix) +function M.delete_zpack_commands(cmd_name) cmd_name = cmd_name or 'ZPack' - legacy_prefix = legacy_prefix or 'Z' pcall(vim.api.nvim_del_user_command, cmd_name) - for _, suffix in ipairs({ 'Update', 'Restore', 'Clean', 'Build', 'Load', 'Delete' }) do - pcall(vim.api.nvim_del_user_command, legacy_prefix .. suffix) - end end return M diff --git a/tests/setup_test.lua b/tests/setup_test.lua index 9cf4600..6be9a2f 100644 --- a/tests/setup_test.lua +++ b/tests/setup_test.lua @@ -28,23 +28,6 @@ describe("Setup and Initialization", function() assert.is_truthy(state.is_setup, "State should still be setup after second call") end) - it("add() shows deprecation error", function() - require('zpack').setup({ spec = {}, defaults = { confirm = false } }) - require('zpack').add({ 'test/plugin' }) - - helpers.flush_pending() - - local found_deprecation = false - for _, notif in ipairs(_G.test_state.notifications) do - if notif.msg:find("REMOVED") and notif.msg:find("add") then - found_deprecation = true - break - end - end - - assert.is_truthy(found_deprecation, "Should show deprecation error for add()") - end) - it("setup() with specs as first argument registers plugins", function() local state = require('zpack.state') diff --git a/tests/validate_test.lua b/tests/validate_test.lua index 0cee212..a407647 100644 --- a/tests/validate_test.lua +++ b/tests/validate_test.lua @@ -57,15 +57,7 @@ describe("Config Validation", function() "error should state the expected type") end) - it("validate_config flags a non-string legacy plugins_dir", function() - local validate = require('zpack.validate') - local errors = validate.validate_config({ plugins_dir = 123 }) - assert.are.equal(1, #errors) - assert.is_truthy(errors[1]:find('plugins_dir', 1, true) ~= nil, - "error should name plugins_dir") - end) - - it("validate_config accepts a merged config (no spec/legacy fields)", function() + it("validate_config accepts a merged config (no spec field)", function() local validate = require('zpack.validate') -- Mirrors what :checkhealth passes: a fully merged zpack.Config. local errors = validate.validate_config({