mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 09:02:40 +00:00
refactor(vim.opt): simplify get_option_metatype
This commit is contained in:
@@ -18,27 +18,18 @@ local key_value_options = {
|
|||||||
--- Convert a vimoption_T style dictionary to the correct OptionType associated with it.
|
--- Convert a vimoption_T style dictionary to the correct OptionType associated with it.
|
||||||
---@return string
|
---@return string
|
||||||
local function get_option_metatype(name, info)
|
local function get_option_metatype(name, info)
|
||||||
if info.type == 'boolean' then
|
if info.type == 'string' then
|
||||||
return 'boolean'
|
|
||||||
elseif info.type == 'number' then
|
|
||||||
return 'number'
|
|
||||||
elseif info.type == 'string' then
|
|
||||||
if not info.commalist and not info.flaglist then
|
|
||||||
return 'string'
|
|
||||||
end
|
|
||||||
|
|
||||||
if key_value_options[name] then
|
|
||||||
assert(info.commalist, 'Must be a comma list to use key:value style')
|
|
||||||
return 'map'
|
|
||||||
end
|
|
||||||
|
|
||||||
if info.flaglist then
|
if info.flaglist then
|
||||||
return 'set'
|
return 'set'
|
||||||
elseif info.commalist then
|
elseif info.commalist then
|
||||||
|
if key_value_options[name] then
|
||||||
|
return 'map'
|
||||||
|
end
|
||||||
return 'array'
|
return 'array'
|
||||||
end
|
end
|
||||||
|
return 'string'
|
||||||
end
|
end
|
||||||
error('Not a known info.type:' .. info.type)
|
return info.type
|
||||||
end
|
end
|
||||||
|
|
||||||
local options_info = setmetatable({}, {
|
local options_info = setmetatable({}, {
|
||||||
|
|||||||
Reference in New Issue
Block a user