From c2dd07448ff1b2922e8ea14f909a9cbde481e5fc Mon Sep 17 00:00:00 2001 From: Keerthan Jaic Date: Tue, 4 Aug 2015 21:41:38 -0400 Subject: option,main: Partial support of XDG base directory specification - Add functions that are able to query XDG. - Replace defaults for - &runtimepath. Does not follow #78. - &viewdir. - &undodir. - &directory. - &backupdir. Does not follow #78. - vimrc location. - Remove user vimrc file line from :version message. --- src/nvim/os/stdpaths.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/nvim/os/stdpaths.c (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c new file mode 100644 index 0000000000..230e760d7d --- /dev/null +++ b/src/nvim/os/stdpaths.c @@ -0,0 +1,100 @@ +#include "nvim/os/os.h" +#include "nvim/strings.h" +#include "nvim/path.h" +#include "nvim/garray.h" + +typedef enum { + kXDGConfigHome, + kXDGDataHome, + kXDGCacheHome, + kXDGRuntimeDir, + kXDGConfigDirs, + kXDGDataDirs, +} XDGDirType; + +static const char *xdg_env_vars[] = { + [kXDGConfigHome] = "XDG_CONFIG_HOME", + [kXDGDataHome] = "XDG_DATA_HOME", + [kXDGCacheHome] = "XDG_CACHE_HOME", + [kXDGRuntimeDir] = "XDG_RUNTIME_DIR", + [kXDGConfigDirs] = "XDG_CONFIG_DIRS", + [kXDGDataDirs] = "XDG_DATA_DIRS", +}; + +static const char *const xdg_defaults[] = { + // Windows, Apple stuff are just shims right now +#ifdef WIN32 + // Windows +#elif APPLE + // Apple (this includes iOS, which we might need to handle differently) + [kXDGConfigHome] = "~/Library/Preferences", + [kXDGDataHome] = "~/Library/Application Support", + [kXDGCacheHome] = "~/Library/Caches", + [kXDGRuntimeDir] = "~/Library/Application Support", + [kXDGConfigDirs] = "/Library/Application Support", + [kXDGDataDirs] = "/Library/Application Support", +#else + // Linux, BSD, CYGWIN + [kXDGConfigHome] = "~/.config", + [kXDGDataHome] = "~/.local/share", + [kXDGCacheHome] = "~/.cache", + [kXDGRuntimeDir] = "", + [kXDGConfigDirs] = "/etc/xdg/", + [kXDGDataDirs] = "/usr/local/share/:/usr/share/", +}; +#endif + +static const char *get_xdg(XDGDirType idx) +{ + const char *env = xdg_env_vars[idx]; + const char *fallback = xdg_defaults[idx]; + + const char *ret = os_getenv(env); + if (!ret && fallback) { + ret = (const char *)expand_env_save((char_u *)fallback); + } + + return ret; +} + +static const char *get_xdg_home(XDGDirType idx) +{ + const char *dir = get_xdg(idx); + if (dir) { + dir = (const char *)concat_fnames(dir, "nvim", true); + } + return dir; +} + +static void create_dir(const char *dir, int mode, const char *suffix) +{ + char *failed; + if (!os_mkdir_recurse(dir, mode, &failed)) { + // TODO: Create a folder in $TMPDIR instead + DLOG("Create dir failed"); + } +} + +const char *get_user_conf_dir(void) +{ + return get_xdg_home(kXDGConfigHome); +} + +const char *get_from_user_conf(const char * fname) +{ + return (const char *)concat_fnames(get_user_conf_dir(), fname, true); +} + +const char *get_user_data_dir(void) +{ + return get_xdg_home(kXDGDataHome); +} + +const char *get_from_user_data(const char * fname) +{ + const char *dir = (const char *)concat_fnames(get_user_data_dir(), fname, true); + if (!os_isdir((char_u *)dir)) { + create_dir(dir, 0755, fname); + } + return dir; +} -- cgit From 1db5a807b203634de608f68e76387fcf0a7857d7 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 14:17:16 +0300 Subject: stdpaths: Fix some issues, specifically - Remove/add includes - Do not pretend that returns are const - Add function attributes - Allocate memory always in get_xdg --- src/nvim/os/stdpaths.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 230e760d7d..e8cfba8b3a 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -1,7 +1,8 @@ +#include + #include "nvim/os/os.h" -#include "nvim/strings.h" #include "nvim/path.h" -#include "nvim/garray.h" +#include "nvim/memory.h" typedef enum { kXDGConfigHome, @@ -44,29 +45,35 @@ static const char *const xdg_defaults[] = { }; #endif -static const char *get_xdg(XDGDirType idx) +static char *get_xdg(const XDGDirType idx) + FUNC_ATTR_WARN_UNUSED_RESULT { - const char *env = xdg_env_vars[idx]; - const char *fallback = xdg_defaults[idx]; + const char *const env = xdg_env_vars[idx]; + const char *const fallback = xdg_defaults[idx]; - const char *ret = os_getenv(env); - if (!ret && fallback) { - ret = (const char *)expand_env_save((char_u *)fallback); + const char *const env_val = os_getenv(env); + char *ret = NULL; + if (env_val != NULL) { + ret = xstrdup(env_val); + } else if (fallback) { + ret = (char *) expand_env_save((char_u *)fallback); } return ret; } -static const char *get_xdg_home(XDGDirType idx) +static char *get_xdg_home(XDGDirType idx) + FUNC_ATTR_WARN_UNUSED_RESULT { - const char *dir = get_xdg(idx); + char *dir = get_xdg(idx); if (dir) { - dir = (const char *)concat_fnames(dir, "nvim", true); + dir = concat_fnames(dir, "nvim", true); } return dir; } static void create_dir(const char *dir, int mode, const char *suffix) + FUNC_ATTR_NONNULL_ALL { char *failed; if (!os_mkdir_recurse(dir, mode, &failed)) { @@ -75,24 +82,28 @@ static void create_dir(const char *dir, int mode, const char *suffix) } } -const char *get_user_conf_dir(void) +char *get_user_conf_dir(void) + FUNC_ATTR_WARN_UNUSED_RESULT { return get_xdg_home(kXDGConfigHome); } -const char *get_from_user_conf(const char * fname) +char *get_from_user_conf(const char *fname) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - return (const char *)concat_fnames(get_user_conf_dir(), fname, true); + return concat_fnames(get_user_conf_dir(), fname, true); } -const char *get_user_data_dir(void) +char *get_user_data_dir(void) + FUNC_ATTR_WARN_UNUSED_RESULT { return get_xdg_home(kXDGDataHome); } -const char *get_from_user_data(const char * fname) +char *get_from_user_data(const char *fname) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - const char *dir = (const char *)concat_fnames(get_user_data_dir(), fname, true); + char *dir = concat_fnames(get_user_data_dir(), fname, true); if (!os_isdir((char_u *)dir)) { create_dir(dir, 0755, fname); } -- cgit From 120ec8c2eab21dc44baa0c4814cb004fd3db6e54 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 14:37:13 +0300 Subject: stdpaths: Remove useless functions get_user_*_dir --- src/nvim/os/stdpaths.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index e8cfba8b3a..0380c9ea37 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -11,7 +11,7 @@ typedef enum { kXDGRuntimeDir, kXDGConfigDirs, kXDGDataDirs, -} XDGDirType; +} XDGVarType; static const char *xdg_env_vars[] = { [kXDGConfigHome] = "XDG_CONFIG_HOME", @@ -45,7 +45,7 @@ static const char *const xdg_defaults[] = { }; #endif -static char *get_xdg(const XDGDirType idx) +static char *get_xdg(const XDGVarType idx) FUNC_ATTR_WARN_UNUSED_RESULT { const char *const env = xdg_env_vars[idx]; @@ -62,7 +62,7 @@ static char *get_xdg(const XDGDirType idx) return ret; } -static char *get_xdg_home(XDGDirType idx) +static char *get_xdg_home(const XDGVarType idx) FUNC_ATTR_WARN_UNUSED_RESULT { char *dir = get_xdg(idx); @@ -82,28 +82,16 @@ static void create_dir(const char *dir, int mode, const char *suffix) } } -char *get_user_conf_dir(void) - FUNC_ATTR_WARN_UNUSED_RESULT -{ - return get_xdg_home(kXDGConfigHome); -} - char *get_from_user_conf(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - return concat_fnames(get_user_conf_dir(), fname, true); -} - -char *get_user_data_dir(void) - FUNC_ATTR_WARN_UNUSED_RESULT -{ - return get_xdg_home(kXDGDataHome); + return concat_fnames(get_xdg_home(kXDGConfigHome), fname, true); } char *get_from_user_data(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - char *dir = concat_fnames(get_user_data_dir(), fname, true); + char *dir = concat_fnames(get_xdg_home(kXDGDataHome), fname, true); if (!os_isdir((char_u *)dir)) { create_dir(dir, 0755, fname); } -- cgit From afb0f2f9b14f0ebcb5c53a47338a6a4359019e38 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 14:40:27 +0300 Subject: stdpaths: Rename export functions so that they have common prefix --- src/nvim/os/stdpaths.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 0380c9ea37..b8ce400276 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -82,13 +82,13 @@ static void create_dir(const char *dir, int mode, const char *suffix) } } -char *get_from_user_conf(const char *fname) +char *stdpaths_user_conf_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { return concat_fnames(get_xdg_home(kXDGConfigHome), fname, true); } -char *get_from_user_data(const char *fname) +char *stdpaths_user_data_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { char *dir = concat_fnames(get_xdg_home(kXDGDataHome), fname, true); -- cgit From be91bc1e1a110da938201eab9b43736e64a7392e Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 14:45:53 +0300 Subject: stdpaths: Export get_xdg function (renamed) and use it for runtimepath --- src/nvim/os/stdpaths.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index b8ce400276..86daa7257a 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -1,18 +1,10 @@ #include +#include "nvim/os/stdpaths_defs.h" #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/memory.h" -typedef enum { - kXDGConfigHome, - kXDGDataHome, - kXDGCacheHome, - kXDGRuntimeDir, - kXDGConfigDirs, - kXDGDataDirs, -} XDGVarType; - static const char *xdg_env_vars[] = { [kXDGConfigHome] = "XDG_CONFIG_HOME", [kXDGDataHome] = "XDG_DATA_HOME", @@ -45,7 +37,7 @@ static const char *const xdg_defaults[] = { }; #endif -static char *get_xdg(const XDGVarType idx) +char *stdpaths_get_xdg_var(const XDGVarType idx) FUNC_ATTR_WARN_UNUSED_RESULT { const char *const env = xdg_env_vars[idx]; @@ -65,7 +57,7 @@ static char *get_xdg(const XDGVarType idx) static char *get_xdg_home(const XDGVarType idx) FUNC_ATTR_WARN_UNUSED_RESULT { - char *dir = get_xdg(idx); + char *dir = stdpaths_get_xdg_var(idx); if (dir) { dir = concat_fnames(dir, "nvim", true); } -- cgit From 502a20a8feb80e7e12eb34231975257b915e3115 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 15:32:11 +0300 Subject: stdpaths,main: Remove all remaining memory leaks --- src/nvim/os/stdpaths.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 86daa7257a..9d93f25a7e 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -59,7 +59,7 @@ static char *get_xdg_home(const XDGVarType idx) { char *dir = stdpaths_get_xdg_var(idx); if (dir) { - dir = concat_fnames(dir, "nvim", true); + dir = concat_fnames_realloc(dir, "nvim", true); } return dir; } @@ -77,13 +77,13 @@ static void create_dir(const char *dir, int mode, const char *suffix) char *stdpaths_user_conf_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - return concat_fnames(get_xdg_home(kXDGConfigHome), fname, true); + return concat_fnames_realloc(get_xdg_home(kXDGConfigHome), fname, true); } char *stdpaths_user_data_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - char *dir = concat_fnames(get_xdg_home(kXDGDataHome), fname, true); + char *dir = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); if (!os_isdir((char_u *)dir)) { create_dir(dir, 0755, fname); } -- cgit From a06a8bad6080e605c25124446c7441cee8911234 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 15:48:38 +0300 Subject: stdpaths: Give proper error message in case directory creation failed --- src/nvim/os/stdpaths.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 9d93f25a7e..e242cd3d69 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -64,13 +64,15 @@ static char *get_xdg_home(const XDGVarType idx) return dir; } -static void create_dir(const char *dir, int mode, const char *suffix) +static void create_dir(const char *dir, int mode) FUNC_ATTR_NONNULL_ALL { char *failed; - if (!os_mkdir_recurse(dir, mode, &failed)) { - // TODO: Create a folder in $TMPDIR instead - DLOG("Create dir failed"); + int err; + if ((err = os_mkdir_recurse(dir, mode, &failed)) != 0) { + EMSG3(_("E920: Failed to create data directory %s: %s"), failed, + os_strerror(-err)); + xfree(failed); } } @@ -85,7 +87,7 @@ char *stdpaths_user_data_subpath(const char *fname) { char *dir = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); if (!os_isdir((char_u *)dir)) { - create_dir(dir, 0755, fname); + create_dir(dir, 0755); } return dir; } -- cgit From a1b0f4073deb7f50e1b7137174bcb9914c97078f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 15:51:31 +0300 Subject: stdpaths: Do NOT create data directories This is none of option.c business to create *possibly unneeded* **default** directories **before** user specified where he actually wants to place the files. --- src/nvim/os/stdpaths.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index e242cd3d69..167a53c985 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -64,18 +64,6 @@ static char *get_xdg_home(const XDGVarType idx) return dir; } -static void create_dir(const char *dir, int mode) - FUNC_ATTR_NONNULL_ALL -{ - char *failed; - int err; - if ((err = os_mkdir_recurse(dir, mode, &failed)) != 0) { - EMSG3(_("E920: Failed to create data directory %s: %s"), failed, - os_strerror(-err)); - xfree(failed); - } -} - char *stdpaths_user_conf_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { @@ -85,9 +73,5 @@ char *stdpaths_user_conf_subpath(const char *fname) char *stdpaths_user_data_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - char *dir = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); - if (!os_isdir((char_u *)dir)) { - create_dir(dir, 0755); - } - return dir; + return concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); } -- cgit From aadaa1fed4d471fc2e286b0ffa151c006482389e Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 21:30:52 +0300 Subject: stdpaths: Add documentation --- src/nvim/os/stdpaths.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 167a53c985..0ed7aec2a6 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -5,6 +5,7 @@ #include "nvim/path.h" #include "nvim/memory.h" +/// Names of the environment variables, mapped to XDGVarType values static const char *xdg_env_vars[] = { [kXDGConfigHome] = "XDG_CONFIG_HOME", [kXDGDataHome] = "XDG_DATA_HOME", @@ -14,6 +15,9 @@ static const char *xdg_env_vars[] = { [kXDGDataDirs] = "XDG_DATA_DIRS", }; +/// Defaults for XDGVarType values +/// +/// Used in case environment variables contain nothing. Need to be expanded. static const char *const xdg_defaults[] = { // Windows, Apple stuff are just shims right now #ifdef WIN32 @@ -37,6 +41,11 @@ static const char *const xdg_defaults[] = { }; #endif +/// Return XDG variable value +/// +/// @param[in] idx XDG variable to use. +/// +/// @return [allocated] variable value. char *stdpaths_get_xdg_var(const XDGVarType idx) FUNC_ATTR_WARN_UNUSED_RESULT { @@ -54,6 +63,11 @@ char *stdpaths_get_xdg_var(const XDGVarType idx) return ret; } +/// Return nvim-specific XDG directory subpath +/// +/// @param[in] idx XDG directory to use. +/// +/// @return [allocated] `{xdg_directory}/nvim` static char *get_xdg_home(const XDGVarType idx) FUNC_ATTR_WARN_UNUSED_RESULT { @@ -64,12 +78,22 @@ static char *get_xdg_home(const XDGVarType idx) return dir; } +/// Return subpath of $XDG_CONFIG_HOME +/// +/// @param[in] fname New component of the path. +/// +/// @return [allocated] `$XDG_CONFIG_HOME/nvim/{fname}` char *stdpaths_user_conf_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { return concat_fnames_realloc(get_xdg_home(kXDGConfigHome), fname, true); } +/// Return subpath of $XDG_DATA_HOME +/// +/// @param[in] fname New component of the path. +/// +/// @return [allocated] `$XDG_DATA_HOME/nvim/{fname}` char *stdpaths_user_data_subpath(const char *fname) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { -- cgit From a82a059921f36fb580026ef4cc31f64c110d07b7 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 21:46:30 +0300 Subject: option: Add `//` to the end of default `&directory` --- src/nvim/os/stdpaths.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 0ed7aec2a6..d4bff65312 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -92,10 +92,19 @@ char *stdpaths_user_conf_subpath(const char *fname) /// Return subpath of $XDG_DATA_HOME /// /// @param[in] fname New component of the path. +/// @param[in] trailing_pathseps Amount of trailing path separators to add. /// /// @return [allocated] `$XDG_DATA_HOME/nvim/{fname}` -char *stdpaths_user_data_subpath(const char *fname) +char *stdpaths_user_data_subpath(const char *fname, + const size_t trailing_pathseps) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - return concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); + char *ret = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true); + if (trailing_pathseps) { + const size_t len = strlen(ret); + ret = xrealloc(ret, len + trailing_pathseps + 1); + memset(ret + len, PATHSEP, trailing_pathseps); + ret[len + trailing_pathseps] = NUL; + } + return ret; } -- cgit From fee3c320484f8444b6b078bdff6777a7aac31c89 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 21:56:27 +0300 Subject: stdpaths: Remove Apple defaults, use \*nix ones instead --- src/nvim/os/stdpaths.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index d4bff65312..520836b983 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -22,24 +22,16 @@ static const char *const xdg_defaults[] = { // Windows, Apple stuff are just shims right now #ifdef WIN32 // Windows -#elif APPLE - // Apple (this includes iOS, which we might need to handle differently) - [kXDGConfigHome] = "~/Library/Preferences", - [kXDGDataHome] = "~/Library/Application Support", - [kXDGCacheHome] = "~/Library/Caches", - [kXDGRuntimeDir] = "~/Library/Application Support", - [kXDGConfigDirs] = "/Library/Application Support", - [kXDGDataDirs] = "/Library/Application Support", #else - // Linux, BSD, CYGWIN + // Linux, BSD, CYGWIN, Apple [kXDGConfigHome] = "~/.config", [kXDGDataHome] = "~/.local/share", [kXDGCacheHome] = "~/.cache", [kXDGRuntimeDir] = "", [kXDGConfigDirs] = "/etc/xdg/", [kXDGDataDirs] = "/usr/local/share/:/usr/share/", -}; #endif +}; /// Return XDG variable value /// -- cgit From d2e07c8307af8a1ab37e68746a8ba600ee372948 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 17 Oct 2015 23:18:04 +0300 Subject: stdpaths: Add missing include --- src/nvim/os/stdpaths.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 520836b983..6e5e37ec08 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -4,6 +4,7 @@ #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/memory.h" +#include "nvim/ascii.h" /// Names of the environment variables, mapped to XDGVarType values static const char *xdg_env_vars[] = { -- cgit From 181c377697b8d4ef8234d3881466837ebae43f69 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 18 Oct 2015 00:24:23 +0300 Subject: stdpaths: Add Windows-specific directories --- src/nvim/os/stdpaths.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 6e5e37ec08..ef20fe0883 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -23,6 +23,12 @@ static const char *const xdg_defaults[] = { // Windows, Apple stuff are just shims right now #ifdef WIN32 // Windows + [kXDGConfigHome] = "$LOCALAPPDATA\\nvim\\config", + [kXDGDataHome] = "$LOCALAPPDATA\\nvim\\data", + [kXDGCacheHome] = "$LOCALAPPDATA\\nvim\\cache", + [kXDGRuntimeDir] = "", + [kXDGConfigDirs] = NULL, + [kXDGDataDirs] = NULL, #else // Linux, BSD, CYGWIN, Apple [kXDGConfigHome] = "~/.config", -- cgit From 198ba323b89fbfb5ea254ec7595a5c58ba7d2aa4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 18 Oct 2015 00:35:30 +0300 Subject: stdpaths: Remove outdated comment --- src/nvim/os/stdpaths.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/os/stdpaths.c') diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index ef20fe0883..ce374828f9 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -20,7 +20,6 @@ static const char *xdg_env_vars[] = { /// /// Used in case environment variables contain nothing. Need to be expanded. static const char *const xdg_defaults[] = { - // Windows, Apple stuff are just shims right now #ifdef WIN32 // Windows [kXDGConfigHome] = "$LOCALAPPDATA\\nvim\\config", -- cgit