mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
refactor(api): give "hl_group" more accurate _meta type
These can either be number or string in lua, so we can specify this directly as "number|string".
This commit is contained in:
parent
646fdf1073
commit
d66ed4ea46
10
runtime/lua/vim/_meta/api_keysets.lua
generated
10
runtime/lua/vim/_meta/api_keysets.lua
generated
@ -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
|
||||
|
@ -88,6 +88,7 @@ local API_TYPES = {
|
||||
LuaRef = 'function',
|
||||
Dictionary = 'table<string,any>',
|
||||
Float = 'number',
|
||||
HLGroupID = 'number|string',
|
||||
void = '',
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user