aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-28 06:02:49 +0800
committerGitHub <noreply@github.com>2024-03-28 06:02:49 +0800
commit7168000b53eb2da9a910ba038c3aa93822d3f196 (patch)
tree8bc9ea126fcb3f18746b2cefac8eaf3a91a7ec3f /src/nvim/generators
parent997bef54aa67cdaaed3cffbdbdaf5933e9718319 (diff)
downloadrneovim-7168000b53eb2da9a910ba038c3aa93822d3f196.tar.gz
rneovim-7168000b53eb2da9a910ba038c3aa93822d3f196.tar.bz2
rneovim-7168000b53eb2da9a910ba038c3aa93822d3f196.zip
refactor(options): require `enable_if = false` iff no variable (#28050)
This makes grepping for unsupported options easier.
Diffstat (limited to 'src/nvim/generators')
-rw-r--r--src/nvim/generators/gen_options.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua
index c0c0d6e0b4..0718d965c6 100644
--- a/src/nvim/generators/gen_options.lua
+++ b/src/nvim/generators/gen_options.lua
@@ -165,17 +165,22 @@ local function dump_option(i, o)
w(get_cond(o.enable_if))
end
- -- Options cannot be both hidden and immutable.
+ -- An option cannot be both hidden and immutable.
assert(not o.hidden or not o.immutable)
+ local has_var = true
if o.varname then
w(' .var=&' .. o.varname)
- -- Hidden and immutable options can directly point to the default value.
elseif o.hidden or o.immutable then
+ -- Hidden and immutable options can directly point to the default value.
w((' .var=&options[%u].def_val'):format(i - 1))
elseif #o.scope == 1 and o.scope[1] == 'window' then
w(' .var=VAR_WIN')
+ else
+ has_var = false
end
+ -- `enable_if = false` should be present iff there is no variable.
+ assert((o.enable_if == false) == not has_var)
w(' .hidden=' .. (o.hidden and 'true' or 'false'))
w(' .immutable=' .. (o.immutable and 'true' or 'false'))
if #o.scope == 1 and o.scope[1] == 'global' then