mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
fix(options): better handling of empty values
Problem: Whether an option is allowed to be empty isn't well defined and isn't properly checked. Solution: - For non-list string options, explicitly check the option value if it is empty. - Annotate non-list string options that can accept an empty value. - Adjust command completion to ignore the empty value. - Render values in Lua meta files
This commit is contained in:
committed by
Lewis Russell
parent
cb7b4e2962
commit
34e2185022
@ -666,7 +666,16 @@ local function render_option_meta(_f, opt, write)
|
||||
write('--- ' .. l)
|
||||
end
|
||||
|
||||
write('--- @type ' .. OPTION_TYPES[opt.type])
|
||||
if opt.type == 'string' and not opt.list and opt.values then
|
||||
local values = {} --- @type string[]
|
||||
for _, e in ipairs(opt.values) do
|
||||
values[#values + 1] = fmt("'%s'", e)
|
||||
end
|
||||
write('--- @type ' .. table.concat(values, '|'))
|
||||
else
|
||||
write('--- @type ' .. OPTION_TYPES[opt.type])
|
||||
end
|
||||
|
||||
write('vim.o.' .. opt.full_name .. ' = ' .. render_option_default(opt.defaults))
|
||||
if opt.abbreviation then
|
||||
write('vim.o.' .. opt.abbreviation .. ' = vim.o.' .. opt.full_name)
|
||||
|
Reference in New Issue
Block a user