aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/genoptions.lua7
-rw-r--r--src/nvim/option.c18
-rw-r--r--src/nvim/options.lua10
-rw-r--r--test/functional/options/defaults_spec.lua2
4 files changed, 23 insertions, 14 deletions
diff --git a/scripts/genoptions.lua b/scripts/genoptions.lua
index da53d010bd..9f7d94969d 100644
--- a/scripts/genoptions.lua
+++ b/scripts/genoptions.lua
@@ -57,9 +57,14 @@ local get_flags = function(o)
add_flag(redraw_flags[r_flag])
end
end
+ if o.expand then
+ add_flag('P_EXPAND')
+ if o.expand == 'nodefault' then
+ add_flag('P_NO_DEF_EXP')
+ end
+ end
for _, flag_desc in ipairs({
{'alloced'},
- {'expand'},
{'nodefault'},
{'no_mkrc'},
{'vi_def'},
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 81f57522b3..e75cb38c9e 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -236,6 +236,7 @@ typedef struct vimoption {
#define P_NO_ML 0x2000000U ///< not allowed in modeline
#define P_CURSWANT 0x4000000U ///< update curswant required; not needed
///< when there is a redraw flag
+#define P_NO_DEF_EXP 0x8000000U ///< Do not expand default value.
#define HIGHLIGHT_INIT \
"8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText," \
@@ -726,6 +727,9 @@ void set_init_1(void)
* default.
*/
for (opt_idx = 0; options[opt_idx].fullname; opt_idx++) {
+ if (options[opt_idx].flags & P_NO_DEF_EXP) {
+ continue;
+ }
char *p;
if ((options[opt_idx].flags & P_GETTEXT)
&& options[opt_idx].var != NULL) {
@@ -2020,13 +2024,15 @@ static char_u *option_expand(int opt_idx, char_u *val)
if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
return NULL;
- /* If val is longer than MAXPATHL no meaningful expansion can be done,
- * expand_env() would truncate the string. */
- if (val != NULL && STRLEN(val) > MAXPATHL)
- return NULL;
-
- if (val == NULL)
+ if (val == NULL) {
val = *(char_u **)options[opt_idx].var;
+ }
+
+ // If val is longer than MAXPATHL no meaningful expansion can be done,
+ // expand_env() would truncate the string.
+ if (val == NULL || STRLEN(val) > MAXPATHL) {
+ return NULL;
+ }
/*
* Expanding this with NameBuff, expand_env() must not be passed IObuff.
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index d19af4f73f..060ec8c1e1 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -165,7 +165,7 @@ return {
deny_duplicates=true,
secure=true,
vi_def=true,
- expand=true,
+ expand='nodefault',
varname='p_bdir',
defaults={if_true={vi=''}}
},
@@ -616,7 +616,7 @@ return {
deny_duplicates=true,
secure=true,
vi_def=true,
- expand=true,
+ expand='nodefault',
varname='p_dir',
defaults={if_true={vi=''}}
},
@@ -1891,7 +1891,7 @@ return {
deny_duplicates=true,
secure=true,
vi_def=true,
- expand=true,
+ expand='nodefault',
varname='p_rtp',
defaults={if_true={vi=''}}
},
@@ -2507,7 +2507,7 @@ return {
deny_duplicates=true,
secure=true,
vi_def=true,
- expand=true,
+ expand='nodefault',
varname='p_udir',
defaults={if_true={vi=''}}
},
@@ -2568,7 +2568,7 @@ return {
type='string', scope={'global'},
secure=true,
vi_def=true,
- expand=true,
+ expand='nodefault',
varname='p_vdir',
defaults={if_true={vi=''}}
},
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index a36939b0bd..161791ab21 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -76,5 +76,3 @@ describe('startup defaults', function()
end)
end)
end)
-
-