aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-10-17 14:45:53 +0300
committerZyX <kp-pav@yandex.ru>2015-10-23 14:54:10 +0300
commitbe91bc1e1a110da938201eab9b43736e64a7392e (patch)
tree501e6fb5bf85155e421b9fc7d9c291ea2d9be848
parentafb0f2f9b14f0ebcb5c53a47338a6a4359019e38 (diff)
downloadrneovim-be91bc1e1a110da938201eab9b43736e64a7392e.tar.gz
rneovim-be91bc1e1a110da938201eab9b43736e64a7392e.tar.bz2
rneovim-be91bc1e1a110da938201eab9b43736e64a7392e.zip
stdpaths: Export get_xdg function (renamed) and use it for runtimepath
-rw-r--r--src/nvim/option.c8
-rw-r--r--src/nvim/os/os.h1
-rw-r--r--src/nvim/os/stdpaths.c14
-rw-r--r--src/nvim/os/stdpaths_defs.h13
4 files changed, 21 insertions, 15 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index c2236114d6..b879580ff1 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -332,11 +332,11 @@ static char *strcpy_comma_escaped(char *dest, const char *src, const size_t len)
static void set_runtimepath_default(void)
{
size_t rtp_size = 0;
- char *const data_home = vim_getenv("XDG_DATA_HOME");
- char *const config_home = vim_getenv("XDG_CONFIG_HOME");
+ char *const data_home = stdpaths_get_xdg_var(kXDGDataHome);
+ char *const config_home = stdpaths_get_xdg_var(kXDGConfigHome);
char *const vimruntime = vim_getenv("VIMRUNTIME");
- char *const data_dirs = vim_getenv("XDG_DATA_DIRS");
- char *const config_dirs = vim_getenv("XDG_CONFIG_DIRS");
+ char *const data_dirs = stdpaths_get_xdg_var(kXDGDataDirs);
+ char *const config_dirs = stdpaths_get_xdg_var(kXDGConfigDirs);
#define NVIM_SIZE (sizeof("/nvim") - 1)
#define SITE_SIZE (sizeof("/site") - 1)
#define AFTER_SIZE (sizeof("/after") - 1)
diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h
index 198f9ae897..3e89e5a94a 100644
--- a/src/nvim/os/os.h
+++ b/src/nvim/os/os.h
@@ -5,6 +5,7 @@
#include <uv.h>
#include "nvim/os/fs_defs.h"
+#include "nvim/os/stdpaths_defs.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
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 <stdbool.h>
+#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);
}
diff --git a/src/nvim/os/stdpaths_defs.h b/src/nvim/os/stdpaths_defs.h
new file mode 100644
index 0000000000..3b882cd582
--- /dev/null
+++ b/src/nvim/os/stdpaths_defs.h
@@ -0,0 +1,13 @@
+#ifndef NVIM_OS_STDPATHS_DEFS_H
+#define NVIM_OS_STDPATHS_DEFS_H
+
+typedef enum {
+ kXDGConfigHome,
+ kXDGDataHome,
+ kXDGCacheHome,
+ kXDGRuntimeDir,
+ kXDGConfigDirs,
+ kXDGDataDirs,
+} XDGVarType;
+
+#endif // NVIM_OS_STDPATHS_DEFS_H