mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
refactor(options): remove option type macros
Problem: We have `P_(BOOL|NUM|STRING)` macros to represent an option's type, which is redundant because `OptValType` can already do that. The current implementation of option type flags is also too limited to allow adding multitype options in the future. Solution: Remove `P_(BOOL|NUM|STRING)` and replace it with a new `type_flags` attribute in `vimoption_T`. Also do some groundwork for adding multitype options in the future. Side-effects: Attempting to set an invalid keycode option (e.g. `set t_foo=123`) no longer gives an error.
This commit is contained in:
@@ -59,7 +59,7 @@ local LUA_KEYWORDS = {
|
||||
}
|
||||
|
||||
local OPTION_TYPES = {
|
||||
bool = 'boolean',
|
||||
boolean = 'boolean',
|
||||
number = 'integer',
|
||||
string = 'string',
|
||||
}
|
||||
@@ -603,7 +603,7 @@ local function build_option_tags(opt)
|
||||
local tags = { opt.full_name }
|
||||
|
||||
tags[#tags + 1] = opt.abbreviation
|
||||
if opt.type == 'bool' then
|
||||
if opt.type == 'boolean' then
|
||||
for i = 1, #tags do
|
||||
tags[#tags + 1] = 'no' .. tags[i]
|
||||
end
|
||||
@@ -642,7 +642,7 @@ local function render_option_doc(_f, opt, write)
|
||||
name_str = string.format("'%s'", opt.full_name)
|
||||
end
|
||||
|
||||
local otype = opt.type == 'bool' and 'boolean' or opt.type
|
||||
local otype = opt.type == 'boolean' and 'boolean' or opt.type
|
||||
if opt.defaults.doc or opt.defaults.if_true ~= nil or opt.defaults.meta ~= nil then
|
||||
local v = render_option_default(opt.defaults, true)
|
||||
local pad = string.rep('\t', math.max(1, math.ceil((24 - #name_str) / 8)))
|
||||
|
||||
Reference in New Issue
Block a user