diff options
author | ii14 <59243201+ii14@users.noreply.github.com> | 2022-05-16 03:07:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-15 18:07:36 -0700 |
commit | e501e4ed4ba86da12a9b4747fdc326b8366a38be (patch) | |
tree | 8f2425fc38d908df41653b992d56a440eda04499 /runtime/lua/vim/_editor.lua | |
parent | b2799518c7b7f93001e23016c0b8e5a3096afac0 (diff) | |
download | rneovim-e501e4ed4ba86da12a9b4747fdc326b8366a38be.tar.gz rneovim-e501e4ed4ba86da12a9b4747fdc326b8366a38be.tar.bz2 rneovim-e501e4ed4ba86da12a9b4747fdc326b8366a38be.zip |
feat(lua): add traceback to vim.deprecate #18575
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r-- | runtime/lua/vim/_editor.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 98921463b3..dc25d68f61 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -446,11 +446,14 @@ do ---@param msg string Content of the notification to show to the user. ---@param level number|nil One of the values from |vim.log.levels|. ---@param opts table|nil Optional parameters. Unused by default. - function vim.notify_once(msg, level, opts) -- luacheck: no unused args + ---@return boolean true if message was displayed, else false + function vim.notify_once(msg, level, opts) if not notified[msg] then vim.notify(msg, level, opts) notified[msg] = true + return true end + return false end end @@ -784,12 +787,15 @@ end --- be removed. ---@param plugin string|nil Plugin name that the function will be removed --- from. Defaults to "Nvim". -function vim.deprecate(name, alternative, version, plugin) +---@param backtrace boolean|nil Prints backtrace. Defaults to true. +function vim.deprecate(name, alternative, version, plugin, backtrace) local message = name .. ' is deprecated' plugin = plugin or 'Nvim' message = alternative and (message .. ', use ' .. alternative .. ' instead.') or message message = message .. ' See :h deprecated\nThis function will be removed in ' .. plugin .. ' version ' .. version - vim.notify_once(message, vim.log.levels.WARN) + if vim.notify_once(message, vim.log.levels.WARN) and backtrace ~= false then + vim.notify(debug.traceback('', 2):sub(2), vim.log.levels.WARN) + end end require('vim._meta') |