1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-28 01:00:28 +03:00
kakoune/share/kak/kakrc
Justin Frank ab6bc41358 Added shell command completion support to define-command and prompt
This commit also introduces a regression in that I decided that the best way to
avoid overly long and confusing names was to rename the current shell-*
switches to script-*, and have the shell command completion be
shell-completion.

renamed script-{completion,candidates} to shell-script-*

Updated docs with new switch names

Added -shell-completion switch to x11-repl and kitty-repl
2018-10-03 09:46:31 -07:00

50 lines
1.5 KiB
Plaintext

def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \
-shell-script-candidates %{
find -L "${kak_runtime}/colors" "${kak_config}/colors" -type f -name '*\.kak' \
| while read -r filename; do
basename="${filename##*/}"
printf %s\\n "${basename%.*}"
done | sort -u
} \
colorscheme %{ evaluate-commands %sh{
find_colorscheme() {
find -L "${1}" -type f -name "${2}".kak | head -n 1
}
if [ -d "${kak_config}/colors" ]; then
filename=$(find_colorscheme "${kak_config}/colors" "${1}")
fi
if [ -z "${filename}" ]; then
filename=$(find_colorscheme "${kak_runtime}/colors" "${1}")
fi
if [ -n "${filename}" ]; then
printf 'source %%{%s}' "${filename}"
else
echo "echo -markup '{Error}No such colorscheme'"
fi
}}
evaluate-commands %sh{
autoload_directory() {
find -L "$1" -type f -name '*\.kak' \
| sed 's/.*/try %{ source "&" } catch %{ echo -debug Autoload: could not load "&" }/'
}
echo "colorscheme default"
if [ -d "${kak_config}/autoload" ]; then
autoload_directory ${kak_config}/autoload
elif [ -d "${kak_runtime}/autoload" ]; then
autoload_directory ${kak_runtime}/autoload
fi
if [ -f "${kak_runtime}/kakrc.local" ]; then
echo "source '${kak_runtime}/kakrc.local'"
fi
if [ -f "${kak_config}/kakrc" ]; then
echo "source '${kak_config}/kakrc'"
fi
}