Support specifying the user configuration with KAKOUNE_CONFIG_DIR

Fixes #3072
Closes #3081
This commit is contained in:
Maxime Coste 2019-10-10 20:26:27 +11:00
parent f2fa260929
commit 081595fa2f
2 changed files with 20 additions and 8 deletions

View File

@ -148,10 +148,11 @@ one or more \fIfile\fRs to edit
.PP
At startup, if \fB\-n\fR is not specified, Kakoune will try to source the file
\fI../share/kak/kakrc\fR relative to the kak binary. This kak file will then
try to recursively source any files in \fI$XDG_CONFIG_HOME/kak/autoload\fR
(with \fI$XDG_CONFIG_HOME\fR defaulting to \fI$HOME/.config\fR, and falling back
to \fI../share/kak/autoload\fR if that autoload directory does not exist),
and finally \fI$XDG_CONFIG_HOME/kak/kakrc\fR.
try to recursively source any files in \fI$KAKOUNE_CONFIG_DIR/autoload\fR
(with \fI$KAKOUNE_CONFIG_DIR\fR defaulting to \fI$XDG_CONFIG_HOME/kak\fR
if \fI$XDG_CONFIG_HOME\fR is set, \fI$HOME/.config/kak\fR if it is not,
and falling back to \fI../share/kak/autoload\fR if that autoload directory
does not exist), and finally \fI$XDG_CONFIG_HOME/kak/kakrc\fR.
That leads to the following behaviour: by default, with no user autoload
directory, the system wide autoload directory is used, once the user wants
@ -189,6 +190,16 @@ kak \-f "ggO// kak: tabstop=8<esc>" *.c
.RE
.fi
.SH ENVIRONMENT
.TP
.BR KAKOUNE_POSIX_SHELL
Overrides the posix shell binary path to use for \fI%sh{...}\fR expansion.
.TP
.BR KAKOUNE_CONFIG_DIR
Overrides the location of the directory containing kakoune user configuration.
.SH FILES
If not started with the \fB\-n\fR switch, Kakoune will source the \fI../share/kak/kakrc\fR file relative to the kak binary,

View File

@ -123,10 +123,11 @@ String runtime_directory()
String config_directory()
{
StringView config_home = getenv("XDG_CONFIG_HOME");
if (config_home.empty())
if (StringView kak_cfg_dir = getenv("KAKOUNE_CONFIG_DIR"); not kak_cfg_dir.empty())
return kak_cfg_dir.str();
if (StringView xdg_cfg_home = getenv("XDG_CONFIG_HOME"); not xdg_cfg_home.empty())
return format("{}/kak", xdg_cfg_home);
return format("{}/.config/kak", homedir());
return format("{}/kak", config_home);
}
static const EnvVarDesc builtin_env_vars[] = { {