summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-05-30 14:32:04 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-05-30 14:32:04 +0100
commit24263843608164205e3dbe3ded30471f3f2395f3 (patch)
tree6880c8e4438a5db06933b4ed8bd6ac50d5c66ef9
parentc61c76061f7b811c6580b1d03a99541729bb6c9b (diff)
Autoload site wide kak scripts if the user does not have his own autoload folder
-rw-r--r--README.asciidoc76
l---------share/kak/autoload1
-rw-r--r--share/kak/kakrc22
-rw-r--r--src/Makefile1
4 files changed, 37 insertions, 63 deletions
diff --git a/README.asciidoc b/README.asciidoc
index fa5f076d..cba725ba 100644
--- a/README.asciidoc
+++ b/README.asciidoc
@@ -15,7 +15,6 @@ TL;DR
git clone http://github.com/mawww/kakoune.git
cd kakoune/src
make
-make userconfig
./kak
---------------------------------------------
@@ -102,10 +101,6 @@ To build, just type *make* in the src directory
Kakoune can be built on Linux, MacOS, and Cygwin. Due to Kakoune relying heavily
on being in an Unix like environment, no native Windows version is planned.
-To setup a basic configuration on your account, type *make userconfig* in the
-src directory, this will setup an initial $XDG_CONFIG_HOME/kak directory. See
-the _Kakrc_ section for more information.
-
Installing
~~~~~~~~~~
@@ -113,17 +108,6 @@ In order to install kak on your system, rather than running it directly from
it's source directory, type *make install*, you can specify the `PREFIX` and
`DESTDIR` if needed.
-Note that by default, no script files will be read if you do not add links
-to them in $XDG_CONFIG_HOME/kak/autoload. Available script files will be
-installed in $PREFIX/share/kak/rc
-
-If you want to enable all files, set $XDG_CONFIG_HOME/kak/autoload to be
-a symbolic link to the $PREFIX/share/kak/rc directory.
-
-----------------------------------------------
-ln -s /usr/share/kak/rc ~/.config/kak/autoload
-----------------------------------------------
-
[TIP]
.Homebrew (OSX)
====
@@ -591,50 +575,22 @@ line using:
Kakrc
-----
-The kakrc file in `../share/kak/kakrc` (relative to the `kak` binary)
-is a list of kak commands to be executed at startup.
-
-The current behaviour is to execute local user commands in the file
-$HOME/.config/kak/kakrc and in all files in $HOME/.config/kak/autoload
-directory
-
-Place links to the files in `rc/` in your autoload directory in order to
-execute them on startup, or use the runtime command (which sources relative
-to the kak binary) to load them on demand.
-
-Existing commands files are:
-
- * *rc/kakrc.kak*: provides kak commands files autodetection and highlighting
- * *rc/cpp.kak*: provides C/CPP files autodetection and highlighting and the
- `:alt` command for switching from C/CPP file to h/hpp one.
- * *rc/asciidoc.kak*: provides asciidoc files autodetection and highlighting
- * *rc/diff.kak*: provides patches/diff files autodetection and highlighting
- * *rc/git.kak*: provides various git format highlighting (commit message editing,
- interactive rebase)
- * *rc/git-tools.kak*: provides some git integration, like `:git-blame`, `:git-show`
- or `:git-diff-show`
- * *rc/make.kak*: provides the `:make` and `:errjump` commands along with
- highlighting for compiler output.
- * *rc/man.kak*: provides the `:man` command
- * *rc/grep.kak*: provides the `:grep` and `:gjump` commands along with highlighting
- for grep output.
- * *rc/ctags.kak*: provides the `:tag` command to jump on a tag definition using
- exuberant ctags files, this script requires the *readtags* binary, available
- in the exuberant ctags package but not installed by default.
- * *rc/client.kak*: provides the `:new` command to launch a new client on the current
- session, if tmux is detected, launch the client in a new tmux split, else
- launch in a new terminal emulator.
- * *rc/clang.kak*: provides the `:clang-enable-autocomplete` command for C/CPP
- insert mode completion support. This requires the clang++ compiler to be
- available. You can use the `clang_options` option to specify switches to
- be passed to the compiler.
-
-Certain command files defines options, such as `grepcmd` (for `:grep`) `makecmd`
-(for `:make`) or `termcmd` (for `:new`).
-
-Some options are shared with commands. `:grep` and `:make` honor the `toolsclient` option,
-if specified, to open their buffer in it rather than the current client. man honor
-the `docsclient` option for the same purpose.
+If not launched with the `-n` switch, Kakoune will source the
+`../share/kak/kakrc` file (relative to the `kak` binary), which
+will in turn source additional files:
+
+If the `$XDG_CONFIG_HOME/kak/autoload` directory exists, load every
+`*.kak` files in it, and load recursively any subdirectory.
+
+If it does not exists, falls back to the site wide autoload directory
+in `../share/kak/autoload/`.
+
+After that, if it exists, source the `$XDG_CONFIG_HOME/kak/kakrc` file
+which should be used for user configuration.
+
+In order to continue autoloading site-wide files with a local autoload
+directory, just add a symbolic link to `../share/kak/autoload/` into
+your local autoload directory.
Options
-------
diff --git a/share/kak/autoload b/share/kak/autoload
new file mode 120000
index 00000000..0cf5a921
--- /dev/null
+++ b/share/kak/autoload
@@ -0,0 +1 @@
+/home/mawww/prj/kakoune/rc \ No newline at end of file
diff --git a/share/kak/kakrc b/share/kak/kakrc
index f319e832..8a5f77f7 100644
--- a/share/kak/kakrc
+++ b/share/kak/kakrc
@@ -31,16 +31,32 @@ def -shell-params runtime %{ %sh{
}}
%sh{
+ autoload() {
+ dir=$1
+ echo "echo -debug autoloading $dir"
+ for rcfile in ${dir}/*.kak; do
+ echo "echo -debug autoloading $rcfile"
+ echo "try %{ source '${rcfile}' } catch %{ }";
+ done
+ for subdir in ${dir}/*; do
+ if [ -d "$subdir" ]; then
+ autoload $subdir
+ fi
+ done
+ }
+
if [ -n "${XDG_CONFIG_HOME}" ]; then
localconfdir="${XDG_CONFIG_HOME}/kak"
else
localconfdir="$HOME/.config/kak"
fi
+
if [ -d "${localconfdir}/autoload" ]; then
- for rcfile in ${localconfdir}/autoload/*.kak; do
- echo "try %{ source '${rcfile}' } catch %{ }";
- done
+ autoload ${localconfdir}/autoload
+ elif [ -d "${kak_runtime}/autoload" ]; then
+ autoload ${kak_runtime}/autoload
fi
+
if [ -f "${localconfdir}/kakrc" ]; then
echo "source '${localconfdir}/kakrc'"
fi
diff --git a/src/Makefile b/src/Makefile
index 6d706f8e..e0ce7d88 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -59,6 +59,7 @@ install: kak
mkdir -p $(sharedir)/rc
install -m 0644 ../share/kak/kakrc $(sharedir)
install -m 0644 ../rc/* $(sharedir)/rc
+ ln -s $(sharedir)/rc $(sharedir)/autoload
mkdir -p $(docdir)
install -m 0644 ../README.asciidoc $(docdir)
install -m 0644 ../doc/* $(docdir)