fix: another round of type annotation fixes

This commit is contained in:
Lewis Russell
2024-10-31 11:28:02 +00:00
committed by Lewis Russell
parent 0ab4d36254
commit 1d4ba8c1ed
7 changed files with 49 additions and 36 deletions

View File

@ -782,7 +782,8 @@ end
do
--- @alias vim.validate.Validator
--- | type|'callable'
--- | type
--- | 'callable'
--- | (type|'callable')[]
--- | fun(v:any):boolean, string?
@ -1170,11 +1171,13 @@ function vim._defer_deprecated_module(old_name, new_name)
---@param k string
__index = function(_, k)
vim.deprecate(old_name, new_name, '2.0.0', nil, false)
--- @diagnostic disable-next-line:no-unknown
local target = require(new_name)
return target[k]
end,
__call = function(self)
vim.deprecate(old_name, new_name, '2.0.0', nil, false)
--- @diagnostic disable-next-line:no-unknown
local target = require(new_name)
return target(self)
end,
@ -1217,11 +1220,14 @@ local state_restore_order = { 'bo', 'wo', 'go', 'env' }
--- @param context vim.context.mods
--- @return vim.context.state
local get_context_state = function(context)
--- @type vim.context.state
local res = { bo = {}, env = {}, go = {}, wo = {} }
-- Use specific order from possibly most to least intrusive
for _, scope in ipairs(scope_order) do
for name, _ in pairs(context[scope] or {}) do
for name, _ in
pairs(context[scope] or {} --[[@as table<string,any>]])
do
local sc = scope == 'o' and scope_map[vim.api.nvim_get_option_info2(name, {}).scope] or scope
-- Do not override already set state and fall back to `vim.NIL` for
@ -1315,7 +1321,10 @@ function vim._with(context, f)
-- Apply some parts of the context in specific order
-- NOTE: triggers `OptionSet` event
for _, scope in ipairs(scope_order) do
for name, context_value in pairs(context[scope] or {}) do
for name, context_value in
pairs(context[scope] or {} --[[@as table<string,any>]])
do
--- @diagnostic disable-next-line:no-unknown
vim[scope][name] = context_value
end
end
@ -1326,7 +1335,10 @@ function vim._with(context, f)
-- Restore relevant cached values in specific order, global scope last
-- NOTE: triggers `OptionSet` event
for _, scope in ipairs(state_restore_order) do
for name, cached_value in pairs(state[scope]) do
for name, cached_value in
pairs(state[scope] --[[@as table<string,any>]])
do
--- @diagnostic disable-next-line:no-unknown
vim[scope][name] = cached_value
end
end