Windows: XDG: Update default paths. #4403

The previous defaults were including the nvim suffix, causing it to
apear twice in the final paths.

kXDGDataHome and kXDGConfigHome are now set as %LOCALAPPDATA%,
kXDGCacheHome is set as $TEMP.

In Windows there is no distinction between configuration and data
storage, but we don't want to place all files under the same path.
get_xdg_home() now appends a different path suffix for kXDGDataHome.

- Configuration files are saved under %LOCALAPPDATA%\nvim
- Data files are saved under %LOCALAPPDATA%\nvim-data
This commit is contained in:
Rui Abreu Ferreira 2015-10-27 00:23:48 +00:00 committed by Justin M. Keyes
parent 32238018e4
commit 4bfac00aa3
3 changed files with 16 additions and 5 deletions

View File

@ -380,6 +380,8 @@ accordingly. Vim proceeds in this order:
Places for your personal initializations: Places for your personal initializations:
Unix $XDG_CONFIG_HOME/nvim/init.vim Unix $XDG_CONFIG_HOME/nvim/init.vim
(default for $XDG_CONFIG_HOME is ~/.config) (default for $XDG_CONFIG_HOME is ~/.config)
Windows $XDG_CONFIG_HOME/nvim/init.vim
(default for $XDG_CONFIG_HOME is ~/AppData/Local)
The files are searched in the order specified above and only the first The files are searched in the order specified above and only the first
one that is found is read. one that is found is read.

View File

@ -37,9 +37,10 @@ for you), you can edit it this way: >
If you don't have a vimrc file yet, see |init.vim| to find out where you can If you don't have a vimrc file yet, see |init.vim| to find out where you can
create a vimrc file. create a vimrc file.
For Unix and Macintosh this file is always used and is recommended: This file is always used and is recommended:
~/.config/nvim/init.vim ~ ~/.config/nvim/init.vim (Unix and OSX) ~
~/AppData/Local/nvim/init.vim (Windows) ~
The vimrc file can contain all the commands that you type after a colon. The The vimrc file can contain all the commands that you type after a colon. The
most simple ones are for setting options. For example, if you want Vim to most simple ones are for setting options. For example, if you want Vim to

View File

@ -22,9 +22,9 @@ static const char *xdg_env_vars[] = {
static const char *const xdg_defaults[] = { static const char *const xdg_defaults[] = {
#ifdef WIN32 #ifdef WIN32
// Windows // Windows
[kXDGConfigHome] = "$LOCALAPPDATA\\nvim\\config", [kXDGConfigHome] = "$LOCALAPPDATA",
[kXDGDataHome] = "$LOCALAPPDATA\\nvim\\data", [kXDGDataHome] = "$LOCALAPPDATA",
[kXDGCacheHome] = "$LOCALAPPDATA\\nvim\\cache", [kXDGCacheHome] = "$TEMP",
[kXDGRuntimeDir] = NULL, [kXDGRuntimeDir] = NULL,
[kXDGConfigDirs] = NULL, [kXDGConfigDirs] = NULL,
[kXDGDataDirs] = NULL, [kXDGDataDirs] = NULL,
@ -66,12 +66,20 @@ char *stdpaths_get_xdg_var(const XDGVarType idx)
/// @param[in] idx XDG directory to use. /// @param[in] idx XDG directory to use.
/// ///
/// @return [allocated] `{xdg_directory}/nvim` /// @return [allocated] `{xdg_directory}/nvim`
///
/// In WIN32 get_xdg_home(kXDGDataHome) returns `{xdg_directory}/nvim-data` to
/// avoid storing configuration and data files in the same path.
static char *get_xdg_home(const XDGVarType idx) static char *get_xdg_home(const XDGVarType idx)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_WARN_UNUSED_RESULT
{ {
char *dir = stdpaths_get_xdg_var(idx); char *dir = stdpaths_get_xdg_var(idx);
if (dir) { if (dir) {
#if defined(WIN32)
dir = concat_fnames_realloc(dir, (idx == kXDGDataHome ? "nvim-data" : "nvim"),
true);
#else
dir = concat_fnames_realloc(dir, "nvim", true); dir = concat_fnames_realloc(dir, "nvim", true);
#endif
} }
return dir; return dir;
} }