From a27419f3fc540f66567f4559a796cd6758f1bb1f Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 4 Nov 2024 19:00:12 +0600 Subject: feat(options)!: disallow setting hidden options #28400 Problem: There are three different ways of marking an option as hidden, `enable_if = false`, `hidden = true` and `immutable = true`. These also have different behaviors. Options hidden with `enable_if = false` can't have their value fetched using Vim script or the API, but options hidden with `hidden = true` or `immutable = true` can. On the other hand, options with `hidden = true` do not error when trying to set their value, but options with `immutable = true` do. Solution: Remove `enable_if = false`, remove the `hidden` property for options, and use `immutable = true` to mark an option as hidden instead. Also make hidden option variable pointers always point to the default value, which allows fetching the value of every hidden option using Vim script and the API. This does also mean that trying to set a hidden option will now give an error instead of just being ignored. --- scripts/gen_eval_files.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/gen_eval_files.lua') diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index 2928361695..edf95043c5 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -717,7 +717,9 @@ local function get_option_meta() local optinfo = vim.api.nvim_get_all_options_info() local ret = {} --- @type table for _, o in ipairs(opts) do - if not o.immutable and not o.hidden and o.enable_if ~= false and o.desc then + local is_window_option = #o.scope == 1 and o.scope[1] == 'window' + local is_option_hidden = o.immutable and not o.varname and not is_window_option + if not is_option_hidden and o.desc then if o.full_name == 'cmdheight' then table.insert(o.scope, 'tab') end -- cgit