refactor(editor): rename var_accessor to vim_accessor

This commit is contained in:
Yi Ming 2024-11-01 12:28:49 +08:00
parent b34e137e43
commit 5001d14a28

View File

@ -467,16 +467,16 @@ vim.cmd = setmetatable({}, {
end,
})
--- @class (private) vim.var_accessor
--- @class (private) vim.vim_accessor
--- @field [string] any
--- @field [integer] vim.var_accessor
--- @field [integer] vim.vim_accessor
-- These are the vim.env/v/g/o/bo/wo variable magic accessors.
do
--- @param scope string
--- @param handle? false|integer
--- @return vim.var_accessor
local function make_dict_accessor(scope, handle)
--- @return vim.vim_accessor
local function make_vim_accessor(scope, handle)
vim.validate('scope', scope, 'string')
local mt = {}
function mt:__newindex(k, v)
@ -484,18 +484,18 @@ do
end
function mt:__index(k)
if handle == nil and type(k) == 'number' then
return make_dict_accessor(scope, k)
return make_vim_accessor(scope, k)
end
return vim._getvar(scope, handle or 0, k)
end
return setmetatable({}, mt)
end
vim.g = make_dict_accessor('g', false)
vim.v = make_dict_accessor('v', false) --[[@as vim.v]]
vim.b = make_dict_accessor('b')
vim.w = make_dict_accessor('w')
vim.t = make_dict_accessor('t')
vim.g = make_vim_accessor('g', false)
vim.v = make_vim_accessor('v', false) --[[@as vim.v]]
vim.b = make_vim_accessor('b')
vim.w = make_vim_accessor('w')
vim.t = make_vim_accessor('t')
end
--- @deprecated