aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_eval_files.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2025-01-10 10:20:43 +0000
committerLewis Russell <me@lewisr.dev>2025-01-13 16:58:25 +0000
commit34e2185022ab698827b72751d77e218a1b6b6afe (patch)
tree9b8c0fe0a24b77a60e1e6511cfb3e2135b7789af /scripts/gen_eval_files.lua
parentcb7b4e296238b46025de05203c886d67da401728 (diff)
downloadrneovim-34e2185022ab698827b72751d77e218a1b6b6afe.tar.gz
rneovim-34e2185022ab698827b72751d77e218a1b6b6afe.tar.bz2
rneovim-34e2185022ab698827b72751d77e218a1b6b6afe.zip
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
Diffstat (limited to 'scripts/gen_eval_files.lua')
-rwxr-xr-xscripts/gen_eval_files.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua
index f888972f0d..58d3eeeadc 100755
--- a/scripts/gen_eval_files.lua
+++ b/scripts/gen_eval_files.lua
@@ -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)