diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-10-20 16:44:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-20 16:44:39 -0700 |
commit | 86832dcd1922eee37acc26310f72aa70def1514b (patch) | |
tree | d9db0de1011d6b495e62e7a2a90d46de97f06996 /runtime/lua/vim/shared.lua | |
parent | 8c2d45be77299d6eb70165697bc5c29898cdb25e (diff) | |
parent | 18b43c331d8a0ed87d7cbefe2a18543b8e4ad360 (diff) | |
download | rneovim-86832dcd1922eee37acc26310f72aa70def1514b.tar.gz rneovim-86832dcd1922eee37acc26310f72aa70def1514b.tar.bz2 rneovim-86832dcd1922eee37acc26310f72aa70def1514b.zip |
Merge #30840 from justinmk/renamehl
Diffstat (limited to 'runtime/lua/vim/shared.lua')
-rw-r--r-- | runtime/lua/vim/shared.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index d11489b539..fd6a37001d 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -1164,6 +1164,32 @@ function vim._defer_require(root, mod) }) end +--- @private +--- Creates a module alias/shim that lazy-loads a target module. +--- +--- Unlike `vim.defaulttable()` this also: +--- - implements __call +--- - calls vim.deprecate() +--- +--- @param old_name string Name of the deprecated module, which will be shimmed. +--- @param new_name string Name of the new module, which will be loaded by require(). +function vim._defer_deprecated_module(old_name, new_name) + return setmetatable({}, { + ---@param _ table<string, any> + ---@param k string + __index = function(_, k) + vim.deprecate(old_name, new_name, '2.0.0', nil, false) + local target = require(new_name) + return target[k] + end, + __call = function(self) + vim.deprecate(old_name, new_name, '2.0.0', nil, false) + local target = require(new_name) + return target(self) + end, + }) +end + --- @nodoc --- @class vim.context.mods --- @field bo? table<string, any> |