From 081595fa2f46ff6a5ac80e4fbfd408564ee924af Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 10 Oct 2019 20:26:27 +1100 Subject: [PATCH] Support specifying the user configuration with KAKOUNE_CONFIG_DIR Fixes #3072 Closes #3081 --- doc/kak.1 | 19 +++++++++++++++---- src/main.cc | 9 +++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/doc/kak.1 b/doc/kak.1 index 9dec4890..38530979 100644 --- a/doc/kak.1 +++ b/doc/kak.1 @@ -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" *.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, diff --git a/src/main.cc b/src/main.cc index e725afc5..de2dba2d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -123,10 +123,11 @@ String runtime_directory() String config_directory() { - StringView config_home = getenv("XDG_CONFIG_HOME"); - if (config_home.empty()) - return format("{}/.config/kak", homedir()); - return format("{}/kak", config_home); + 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()); } static const EnvVarDesc builtin_env_vars[] = { {