From 3a3474371b6b87e630e7aa217e7860e9154cd563 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Tue, 28 Nov 2023 06:15:26 +0600 Subject: 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. --- src/nvim/options.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/nvim/options.lua') diff --git a/src/nvim/options.lua b/src/nvim/options.lua index c5dfa91f27..daaf73d241 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -6,6 +6,7 @@ --- @field varname? string --- @field pv_name? string --- @field type 'bool'|'number'|'string' +--- @field immutable? boolean --- @field list? 'comma'|'onecomma'|'commacolon'|'onecommacolon'|'flags'|'flagscomma' --- @field scope vim.option_scope[] --- @field deny_duplicates? boolean @@ -1341,7 +1342,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_off', + immutable = true, }, { abbreviation = 'cpt', @@ -2299,7 +2300,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_off', + immutable = true, }, { abbreviation = 'emo', @@ -3885,7 +3886,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_off', + immutable = true, }, { abbreviation = 'hkp', @@ -3894,7 +3895,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_off', + immutable = true, }, { abbreviation = 'hls', @@ -4292,7 +4293,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_off', + immutable = true, }, { abbreviation = 'isf', @@ -6042,7 +6043,7 @@ return { scope = { 'global' }, short_desc = N_('enable prompt in Ex mode'), type = 'bool', - varname = 'p_force_on', + immutable = true, }, { abbreviation = 'pb', @@ -6299,7 +6300,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_on', + immutable = true, }, { defaults = { if_true = 2 }, @@ -8824,7 +8825,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_off', + immutable = true, }, { abbreviation = 'tw', @@ -9069,7 +9070,7 @@ return { scope = { 'global' }, short_desc = N_('No description'), type = 'bool', - varname = 'p_force_on', + immutable = true, }, { abbreviation = 'udir', -- cgit