mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 16:58:17 +00:00
stdpaths: Export get_xdg function (renamed) and use it for runtimepath
This commit is contained in:
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
13
src/nvim/os/stdpaths_defs.h
Normal file
13
src/nvim/os/stdpaths_defs.h
Normal file
@@ -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
|
Reference in New Issue
Block a user