diff options
author | Famiu Haque <famiuhaque@proton.me> | 2023-11-28 06:15:26 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-28 08:15:26 +0800 |
commit | 3a3474371b6b87e630e7aa217e7860e9154cd563 (patch) | |
tree | a1456d9a80c2e00e452601d89964c6bf059a94c2 /src/nvim/generators/gen_options.lua | |
parent | a314703cf1b9ccc654162c5d55b819aee66aa8b6 (diff) | |
download | rneovim-3a3474371b6b87e630e7aa217e7860e9154cd563.tar.gz rneovim-3a3474371b6b87e630e7aa217e7860e9154cd563.tar.bz2 rneovim-3a3474371b6b87e630e7aa217e7860e9154cd563.zip |
refactor(options): replace `p_force_(on|off)` with `immutable` (#26209)
Problem: We use the `p_force_on` and `p_force_off` variables to check if a variable is immutable and what its default value is. This is not only hacky and unintuitive, but also is limited to only boolean options.
Solution: Replace `p_force_on` and `p_force_off` with an `immutable` property for options, which indicates if an option is immutable. Immutable options cannot be changed from their default value.
Ref: #25672.
Diffstat (limited to 'src/nvim/generators/gen_options.lua')
-rw-r--r-- | src/nvim/generators/gen_options.lua | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index c9878bf3b0..26ade2745d 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -143,9 +143,13 @@ local function dump_option(i, o) end if o.varname then w(' .var=&' .. o.varname) + -- Immutable options should directly point to the default value + elseif o.immutable then + w((' .var=&options[%u].def_val'):format(i - 1)) elseif #o.scope == 1 and o.scope[1] == 'window' then w(' .var=VAR_WIN') end + w(' .immutable=' .. (o.immutable and 'true' or 'false')) if #o.scope == 1 and o.scope[1] == 'global' then w(' .indir=PV_NONE') else |