refactor(api): use hl id directly in nvim_buf_set_extmark

This commit is contained in:
glepnir
2024-01-17 20:14:26 +08:00
parent ba9f86a9ce
commit 646fdf1073
7 changed files with 58 additions and 49 deletions

View File

@@ -72,6 +72,7 @@ local keysets = {}
local function add_keyset(val)
local keys = {}
local types = {}
local hlgroups = {}
local is_set_name = 'is_set__' .. val.keyset_name .. '_'
local has_optional = false
for i, field in ipairs(val.fields) do
@@ -80,6 +81,7 @@ local function add_keyset(val)
end
if field.name ~= is_set_name and field.type ~= 'OptionalKeys' then
table.insert(keys, field.name)
hlgroups[field.name] = field.name:find('hl_group') and true or false
else
if i > 1 then
error("'is_set__{type}_' must be first if present")
@@ -91,10 +93,13 @@ local function add_keyset(val)
has_optional = true
end
end
table.insert(
keysets,
{ name = val.keyset_name, keys = keys, types = types, has_optional = has_optional }
)
table.insert(keysets, {
name = val.keyset_name,
keys = keys,
types = types,
hlgroups = hlgroups,
has_optional = has_optional,
})
end
-- read each input file, parse and append to the api metadata
@@ -305,10 +310,12 @@ for _, k in ipairs(keysets) do
.. typename(k.types[key])
.. ', '
.. ind
.. ', '
.. (k.hlgroups[key] and 'true' or 'false')
.. '},\n'
)
end
output:write(' {NULL, 0, kObjectTypeNil, -1},\n')
output:write(' {NULL, 0, kObjectTypeNil, -1, false},\n')
output:write('};\n\n')
output:write(hashfun)