diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua index 377060256a..5ebedc977b 100644 --- a/runtime/lua/vim/_meta/api_keysets.lua +++ b/runtime/lua/vim/_meta/api_keysets.lua @@ -246,7 +246,7 @@ error('Cannot require a meta file') --- @field end_line? integer --- @field end_row? integer --- @field end_col? integer ---- @field hl_group? integer +--- @field hl_group? number|string --- @field virt_text? any[] --- @field virt_text_pos? string --- @field virt_text_win_col? integer @@ -264,10 +264,10 @@ error('Cannot require a meta file') --- @field virt_lines_leftcol? boolean --- @field strict? boolean --- @field sign_text? string ---- @field sign_hl_group? integer ---- @field number_hl_group? integer ---- @field line_hl_group? integer ---- @field cursorline_hl_group? integer +--- @field sign_hl_group? number|string +--- @field number_hl_group? number|string +--- @field line_hl_group? number|string +--- @field cursorline_hl_group? number|string --- @field conceal? string --- @field spell? boolean --- @field ui_watched? boolean diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index c49f598304..499c7dc9a7 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -88,6 +88,7 @@ local API_TYPES = { LuaRef = 'function', Dictionary = 'table', Float = 'number', + HLGroupID = 'number|string', void = '', } diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h index aad8ba3238..b2f0039eb9 100644 --- a/src/nvim/api/keysets_defs.h +++ b/src/nvim/api/keysets_defs.h @@ -28,7 +28,7 @@ typedef struct { Integer end_line; Integer end_row; Integer end_col; - Integer hl_group; + HLGroupID hl_group; Array virt_text; String virt_text_pos; Integer virt_text_win_col; @@ -46,10 +46,10 @@ typedef struct { Boolean virt_lines_leftcol; Boolean strict; String sign_text; - Integer sign_hl_group; - Integer number_hl_group; - Integer line_hl_group; - Integer cursorline_hl_group; + HLGroupID sign_hl_group; + HLGroupID number_hl_group; + HLGroupID line_hl_group; + HLGroupID cursorline_hl_group; String conceal; Boolean spell; Boolean ui_watched; diff --git a/src/nvim/api/private/defs.h b/src/nvim/api/private/defs.h index 84ded1e647..0cdc90e50f 100644 --- a/src/nvim/api/private/defs.h +++ b/src/nvim/api/private/defs.h @@ -124,6 +124,7 @@ struct key_value_pair { }; typedef uint64_t OptionalKeys; +typedef Integer HLGroupID; // this is the prefix of all keysets with optional keys typedef struct { diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 3fb240d70b..2eee1724c0 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -72,7 +72,6 @@ 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 @@ -81,7 +80,6 @@ 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") @@ -97,7 +95,6 @@ local function add_keyset(val) name = val.keyset_name, keys = keys, types = types, - hlgroups = hlgroups, has_optional = has_optional, }) end @@ -285,7 +282,9 @@ for _, k in ipairs(keysets) do keysets_defs:write('extern KeySetLink ' .. k.name .. '_table[];\n') local function typename(type) - if type ~= nil then + if type == 'HLGroupID' then + return 'kObjectTypeInteger' + elseif type ~= nil then return 'kObjectType' .. type else return 'kObjectTypeNil' @@ -311,7 +310,7 @@ for _, k in ipairs(keysets) do .. ', ' .. ind .. ', ' - .. (k.hlgroups[key] and 'true' or 'false') + .. (k.types[key] == 'HLGroupID' and 'true' or 'false') .. '},\n' ) end