Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions doc/zpack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
53 changes: 0 additions & 53 deletions lua/zpack/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 :<cmd_name> 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
103 changes: 0 additions & 103 deletions lua/zpack/deprecation.lua

This file was deleted.

30 changes: 2 additions & 28 deletions lua/zpack/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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()
Expand Down
46 changes: 1 addition & 45 deletions lua/zpack/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 :<Prefix><Suffix> commands; use :<cmd_name> <subcommand>
---@field auto_import? any @deprecated Removed; pass specs to setup() instead

local config = {
cmd_name = 'ZPack',
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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')

Expand All @@ -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|.
Expand Down
5 changes: 0 additions & 5 deletions lua/zpack/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
15 changes: 5 additions & 10 deletions lua/zpack/validate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
Loading
Loading