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.
This commit is contained in:
Famiu Haque
2024-11-04 19:00:12 +06:00
committed by GitHub
parent 04d178053f
commit a27419f3fc
18 changed files with 102 additions and 99 deletions

View File

@ -717,7 +717,9 @@ local function get_option_meta()
local optinfo = vim.api.nvim_get_all_options_info()
local ret = {} --- @type table<string,vim.option_meta>
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