Use shell-candidates for :colorscheme completion

This commit is contained in:
Maxime Coste 2016-09-05 23:39:13 +01:00
parent da0fe5d0bd
commit 9a19f18bc0

View File

@ -6,18 +6,15 @@ def -params 1.. runtime %{ %sh{
}} }}
def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \ def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \
-shell-completion %{ -shell-candidates %{
prefix=$(printf %s "$1" | cut -c1-${kak_pos_in_token} 2> /dev/null)
(
localconfdir=${XDG_CONFIG_HOME:-${HOME}/.config}/kak localconfdir=${XDG_CONFIG_HOME:-${HOME}/.config}/kak
for col in ${kak_runtime}/colors/*.kak ${localconfdir}/colors/*.kak; do for col in ${kak_runtime}/colors/*.kak ${localconfdir}/colors/*.kak; do
candidate=$(basename "${col}" .kak) candidate=$(basename "${col}" .kak)
case ${candidate} in case ${candidate} in
\**) ;; \**) ;;
${prefix}*) echo ${candidate} ;; *) echo ${candidate} ;;
esac esac
done done
) | sort -u
} \ } \
colorscheme %{ %sh{ colorscheme %{ %sh{
localconfdir=${XDG_CONFIG_HOME:-${HOME}/.config}/kak localconfdir=${XDG_CONFIG_HOME:-${HOME}/.config}/kak