-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfzf-tab-source.plugin.zsh
33 lines (30 loc) · 1.11 KB
/
fzf-tab-source.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# https://github.com/zdharma-continuum/Zsh-100-Commits-Club/blob/master/Zsh-Plugin-Standard.adoc
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
function () {
local dir=${1:h} config_directory
local sources=($dir/sources/*.zsh)
# use user's sources to override this plugin's sources
zstyle -s ':fzf-tab:sources' config-directory config_directory &&
sources+=($config_directory/**/*.zsh(.N))
# https://github.com/Freed-Wu/fzf-tab-source/issues/11
# enable $group
zstyle ':completion:*:descriptions' format %d
local src line arr ctx flags
for src in $sources; do
while read -r line; do
# strip code to get magic comment
arr=(${(@s. .)line##\# })
ctx=${arr[1]}
if [[ $ctx == ':fzf-tab:'* ]]; then
break
fi
done < $src
zstyle $ctx fzf-preview "src="\""$src"\"" . "\""$dir"\""/functions/main.zsh"
flags=${arr[2]}
# https://github.com/Aloxaf/fzf-tab/issues/282
# https://github.com/junegunn/fzf/issues/2822
# $word = {2} make a wrong --preview-window=+{2}
zstyle $ctx fzf-flags ${flags:---preview-window=+0}
done
} $0