mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(lua): vim.deprecate does not support major>0
This commit is contained in:
@ -1149,16 +1149,22 @@ function vim.deprecate(name, alternative, version, plugin, backtrace)
|
||||
if plugin == 'Nvim' then
|
||||
require('vim.deprecated.health').add(name, version, traceback(), alternative)
|
||||
|
||||
-- Only issue warning if feature is hard-deprecated as specified by MAINTAIN.md.
|
||||
-- Example: if removal_version is 0.12 (soft-deprecated since 0.10-dev), show warnings starting at
|
||||
-- 0.11, including 0.11-dev
|
||||
-- Show a warning only if feature is hard-deprecated (see MAINTAIN.md).
|
||||
-- Example: if removal `version` is 0.12 (soft-deprecated since 0.10-dev), show warnings
|
||||
-- starting at 0.11, including 0.11-dev.
|
||||
local major, minor = version:match('(%d+)%.(%d+)')
|
||||
major, minor = tonumber(major), tonumber(minor)
|
||||
local nvim_major = 0 --- Current Nvim major version.
|
||||
|
||||
-- We can't "subtract" from a major version, so:
|
||||
-- * Always treat `major > nvim_major` as soft-deprecation.
|
||||
-- * Compare `minor - 1` if `major == nvim_major`.
|
||||
if major > nvim_major then
|
||||
return -- Always soft-deprecation (see MAINTAIN.md).
|
||||
end
|
||||
|
||||
local hard_deprecated_since = string.format('nvim-%d.%d', major, minor - 1)
|
||||
-- Assume there will be no next minor version before bumping up the major version
|
||||
local is_hard_deprecated = minor == 0 or vim.fn.has(hard_deprecated_since) == 1
|
||||
if not is_hard_deprecated then
|
||||
if major == nvim_major and vim.fn.has(hard_deprecated_since) == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user