feat(lua-types): types for vim.api.* (#24523)

This commit is contained in:
Lewis Russell
2023-08-01 14:20:44 +01:00
committed by GitHub
parent e55e80d51c
commit 48d533272e
13 changed files with 2712 additions and 17 deletions

View File

@@ -857,4 +857,6 @@ add_custom_target(generated-sources DEPENDS
${NVIM_GENERATED_SOURCES}
)
add_custom_target(api-metadata DEPENDS ${API_METADATA})
add_subdirectory(po)

View File

@@ -16,9 +16,10 @@
--- @field fast? boolean Function can run in |api-fast| events. Defaults to false.
--- @field deprecated? true
--- @field returns? string|false
--- @field returns_desc? string
--- @field signature string
--- @field desc? string
--- @field params {[1]:string, [2]:string}[]
--- @field params {[1]:string, [2]:string, [3]:string}[]
--- @field lua? false Do not render type information
--- @field tags? string[] Extra tags
--- @field data? string Used by gen_eval.lua

View File

@@ -71,7 +71,7 @@ local function add_keyset(val)
if field.type ~= 'Object' then
error 'not yet implemented: types other than Object'
end
table.insert(keys, field.name)
table.insert(keys, {field.name, field.type})
end
table.insert(keysets, {val.keyset_name, keys})
end
@@ -242,13 +242,16 @@ for _,keyset in ipairs(keysets) do
return key
end
local key_names = {}
for i = 1,#keys do
if vim.endswith(keys[i], "_") then
keys[i] = string.sub(keys[i],1, #(keys[i]) - 1)
special[keys[i]] = true
local kname = keys[i][1]
if vim.endswith(kname, "_") then
kname = string.sub(kname,1, #kname - 1)
special[kname] = true
end
key_names[i] = kname
end
local neworder, hashfun = hashy.hashy_hash(name, keys, function (idx)
local neworder, hashfun = hashy.hashy_hash(name, key_names, function (idx)
return name.."_table["..idx.."].str"
end)
@@ -502,6 +505,7 @@ output:write(hashfun)
output:close()
functions.keysets = keysets
local mpack_output = io.open(mpack_outputf, 'wb')
mpack_output:write(mpack.encode(functions))
mpack_output:close()