aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/options.txt2
-rw-r--r--src/nvim/option.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 3471106afd..7829add2e5 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -901,7 +901,7 @@ A jump table for the options with a short description can be found at |Q_op|.
again not rename the file.
*'backupdir'* *'bdir'*
-'backupdir' 'bdir' string (default "$XDG_DATA_HOME/nvim/backup")
+'backupdir' 'bdir' string (default ".,$XDG_DATA_HOME/nvim/backup")
global
List of directories for the backup file, separated with commas.
- The backup file will be created in the first directory in the list
diff --git a/src/nvim/option.c b/src/nvim/option.c
index f30d10d0bb..cc4df28837 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -685,9 +685,13 @@ void set_init_1(void)
#endif
false);
+ char *backupdir = stdpaths_user_data_subpath("backup", 0);
+ const size_t backupdir_len = strlen(backupdir);
+ backupdir = xrealloc(backupdir, backupdir_len + 3);
+ memmove(backupdir + 2, backupdir, backupdir_len + 1);
+ memmove(backupdir, ".,", 2);
set_string_default("viewdir", stdpaths_user_data_subpath("view", 0), true);
- set_string_default("backupdir", stdpaths_user_data_subpath("backup", 0),
- true);
+ set_string_default("backupdir", backupdir, true);
set_string_default("directory", stdpaths_user_data_subpath("swap", 2), true);
set_string_default("undodir", stdpaths_user_data_subpath("undo", 0), true);
// Set default for &runtimepath. All necessary expansions are performed in