aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-05-16 18:33:09 +0200
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-05-24 11:08:00 +0200
commitd123202ae6ef3f046d5b6579c194dca82ddb8a8f (patch)
treedfb64b7bb09076a58962cb7c41f36f80c02fa992 /test/functional/lua/vim_spec.lua
parentf864b68c5b0fe1482249167712cd16ff2b50ec45 (diff)
downloadrneovim-d123202ae6ef3f046d5b6579c194dca82ddb8a8f.tar.gz
rneovim-d123202ae6ef3f046d5b6579c194dca82ddb8a8f.tar.bz2
rneovim-d123202ae6ef3f046d5b6579c194dca82ddb8a8f.zip
fix: change deprecation presentation
Deprecation with vim.deprecate is currently too noisy. Show the following warning instead: [function] is deprecated. Run ":checkhealth vim.deprecated" for more information. The important part is that the full message needs to be short enough to fit in one line in order to not trigger the "Press ENTER or type command to continue" prompt. The full information and stack trace for the deprecated functions will be shown in the new healthcheck `vim.deprecated`.
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r--test/functional/lua/vim_spec.lua42
1 files changed, 23 insertions, 19 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index dd0c3d3868..c8f94c6ffa 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -135,42 +135,46 @@ describe('lua stdlib', function()
-- See MAINTAIN.md for the soft/hard deprecation policy
describe(('vim.deprecate prerel=%s,'):format(prerel or 'nil'), function()
- it('plugin=nil', function()
- local curver = exec_lua('return vim.version()') --[[@as {major:number, minor:number}]]
- -- "0.10" or "0.10-dev+xxx"
- local curstr = ('%s.%s%s'):format(curver.major, curver.minor, prerel or '')
- -- "0.10" or "0.11"
- local nextver = ('%s.%s'):format(curver.major, curver.minor + (prerel and 0 or 1))
- local was_removed = prerel and 'was removed' or 'will be removed'
-
+ local curver = exec_lua('return vim.version()') --[[@as {major:number, minor:number}]]
+ -- "0.10" or "0.10-dev+xxx"
+ local curstr = ('%s.%s%s'):format(curver.major, curver.minor, prerel or '')
+ -- "0.10" or "0.11"
+ local nextver = ('%s.%s'):format(curver.major, curver.minor + (prerel and 0 or 1))
+ local was_removed = prerel and 'was removed' or 'will be removed'
+
+ it('plugin=nil, same message skipped', function()
eq(
- dedent([[
- foo.bar() is deprecated, use zub.wooo{ok=yay} instead. :help deprecated
- Feature was removed in Nvim %s]]):format(curstr),
+ dedent(
+ [[
+ foo.bar() is deprecated. Run ":checkhealth vim.deprecated" for more information]]
+ ):format(curstr),
exec_lua('return vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', curstr)
)
-- Same message as above; skipped this time.
eq(vim.NIL, exec_lua('return vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', curstr))
+ end)
- -- No error if soft-deprecated.
+ it('plugin=nil, no error if soft-deprecated', function()
eq(
vim.NIL,
exec_lua('return vim.deprecate(...)', 'foo.baz()', 'foo.better_baz()', '0.99.0')
)
+ end)
- -- Show error if hard-deprecated.
+ it('plugin=nil, show error if hard-deprecated', function()
eq(
- dedent([[
- foo.hard_dep() is deprecated, use vim.new_api() instead. :help deprecated
- Feature %s in Nvim %s]]):format(was_removed, nextver),
+ dedent(
+ [[
+ foo.hard_dep() is deprecated. Run ":checkhealth vim.deprecated" for more information]]
+ ):format(was_removed, nextver),
exec_lua('return vim.deprecate(...)', 'foo.hard_dep()', 'vim.new_api()', nextver)
)
+ end)
- -- To be deleted in the next major version (1.0)
+ it('plugin=nil, to be deleted in the next major version (1.0)', function()
eq(
dedent [[
- foo.baz() is deprecated. :help deprecated
- Feature will be removed in Nvim 1.0]],
+ foo.baz() is deprecated. Run ":checkhealth vim.deprecated" for more information]],
exec_lua [[ return vim.deprecate('foo.baz()', nil, '1.0') ]]
)
end)