refactor(api): use typed keysets

Initially this is just for geting rid of boilerplate,
but eventually the types could get exposed as metadata
This commit is contained in:
bfredl
2023-08-01 14:01:19 +02:00
parent c01e624b07
commit 7bc93e0e2f
23 changed files with 771 additions and 866 deletions

View File

@ -260,19 +260,18 @@ local function get_api_keysets()
local ret = {} --- @type table<string, vim.EvalFn>
--- @type {[1]: string, [2]: {[1]: string, [2]: string}[] }[]
--- @type {name: string, keys: string[], types: table<string,string>}[]
local keysets = metadata.keysets
for _, keyset in ipairs(keysets) do
local kname = keyset[1]
local kdef = keyset[2]
for _, field in ipairs(kdef) do
field[2] = api_type(field[2])
for _, k in ipairs(keysets) do
local params = {}
for _, key in ipairs(k.keys) do
table.insert(params, {key, api_type(k.types[key] or 'any')})
end
ret[kname] = {
ret[k.name] = {
signature = 'NA',
name = kname,
params = kdef,
name = k.name,
params = params,
}
end