diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-05-03 15:42:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 06:42:41 -0700 |
commit | 73741e94867a8dedabcbd356e1e929f198c51905 (patch) | |
tree | ebd12a0887d3b6e7d200641344c49fe310ad21cd /runtime/lua/vim/_editor.lua | |
parent | 4fb48c5654d9ffbffbdcdd80d0498b1ea3c8e68b (diff) | |
download | rneovim-73741e94867a8dedabcbd356e1e929f198c51905.tar.gz rneovim-73741e94867a8dedabcbd356e1e929f198c51905.tar.bz2 rneovim-73741e94867a8dedabcbd356e1e929f198c51905.zip |
feat(lua): vim.deprecate() #18320
This is primarily intended to act as documentation for the developer so
they know exactly when and what to remove. This will help prevent the
situation of deprecated code lingering for far too long as developers
don't have to worry if a function is safe to remove.
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r-- | runtime/lua/vim/_editor.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 8e372b806c..62a7b3df13 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -735,6 +735,22 @@ function vim._cs_remote(rcid, server_addr, connect_error, args) } end +--- Display a deprecation notification to the user. +--- +---@param name string Deprecated function. +---@param alternative string|nil Preferred alternative function. +---@param version string Version in which the deprecated function will +--- 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) + 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) +end + require('vim._meta') return vim |