shada: Move shada file to a new location

This commit is contained in:
ZyX
2015-10-17 15:41:05 +03:00
parent 502a20a8fe
commit 2e750973e9
4 changed files with 17 additions and 7 deletions

View File

@@ -2028,7 +2028,7 @@ static void usage(void)
mch_msg(_(" -r, -L List swap files and exit\n")); mch_msg(_(" -r, -L List swap files and exit\n"));
mch_msg(_(" -r <file> Recover crashed session\n")); mch_msg(_(" -r <file> Recover crashed session\n"));
mch_msg(_(" -u <nvimrc> Use <nvimrc> instead of the default\n")); mch_msg(_(" -u <nvimrc> Use <nvimrc> instead of the default\n"));
mch_msg(_(" -i <shada> Use <shada> instead of the default " SHADA_FILE "\n")); // NOLINT(whitespace/line_length) mch_msg(_(" -i <shada> Use <shada> instead of the default\n"));
mch_msg(_(" --noplugin Don't load plugin scripts\n")); mch_msg(_(" --noplugin Don't load plugin scripts\n"));
mch_msg(_(" -o[N] Open N windows (default: one for each file)\n")); mch_msg(_(" -o[N] Open N windows (default: one for each file)\n"));
mch_msg(_(" -O[N] Like -o but split vertically\n")); mch_msg(_(" -O[N] Like -o but split vertically\n"));

View File

@@ -37,8 +37,5 @@
#ifndef VIMRC_FILE #ifndef VIMRC_FILE
# define VIMRC_FILE ".nvimrc" # define VIMRC_FILE ".nvimrc"
#endif #endif
#ifndef SHADA_FILE
# define SHADA_FILE "~/.nvim/shada/main.shada"
#endif
#endif // NVIM_OS_UNIX_DEFS_H #endif // NVIM_OS_UNIX_DEFS_H

View File

@@ -8,7 +8,6 @@
// Defines needed to fix the build on Windows: // Defines needed to fix the build on Windows:
// - USR_EXRC_FILE // - USR_EXRC_FILE
// - SHADA_FILE
// - DFLT_DIR // - DFLT_DIR
// - DFLT_BDIR // - DFLT_BDIR
// - DFLT_VDIR // - DFLT_VDIR

View File

@@ -1583,6 +1583,20 @@ shada_read_main_cycle_end:
kh_dealloc(strset, &oldfiles_set); kh_dealloc(strset, &oldfiles_set);
} }
/// Default shada file location: cached path
static char *default_shada_file = NULL;
/// Get the default ShaDa file
static const char *shada_get_default_file(void)
FUNC_ATTR_WARN_UNUSED_RESULT
{
if (default_shada_file == NULL) {
char *shada_dir = stdpaths_user_data_subpath("shada");
default_shada_file = concat_fnames_realloc(shada_dir, "main.shada", true);
}
return default_shada_file;
}
/// Get the ShaDa file name to use /// Get the ShaDa file name to use
/// ///
/// If "file" is given and not empty, use it (has already been expanded by /// If "file" is given and not empty, use it (has already been expanded by
@@ -1608,11 +1622,11 @@ static char *shada_filename(const char *file)
if (STRCMP("$VIM", NameBuff) != 0) { // $VIM was expanded if (STRCMP("$VIM", NameBuff) != 0) { // $VIM was expanded
file = SHADA_FILE2; file = SHADA_FILE2;
} else { } else {
file = SHADA_FILE; file = shada_get_default_file();
} }
} else { } else {
#endif #endif
file = SHADA_FILE; file = shada_get_default_file();
#ifdef SHADA_FILE2 #ifdef SHADA_FILE2
} }
#endif #endif