-
-
Notifications
You must be signed in to change notification settings - Fork 141
/
.autocomplete.key-binding
83 lines (73 loc) 路 3.01 KB
/
.autocomplete.key-binding
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/zsh
zmodload zsh/complist
zmodload -Fa zsh/parameter p:funcstack p:functions
.autocomplete.key-binding.precmd() {
# Work around plugin managers making `key` local.
[[ -z $key[Tab] || -z $key[Shift-Tab] ]] &&
source ~zsh-autocomplete/module/.autocomplete.key
local tab_style; zstyle -s :autocomplete:tab: widget-style tab_style ||
tab_style='complete-word'
if zstyle -t :autocomplete:tab: fzf || zstyle -t :autocomplete:tab: fzf-completion; then
typeset -gH fzf_default_completion=$tab_style
functions[.autocomplete.fzf-completion]=$functions[fzf-completion]
fzf-completion() {
zle() {
builtin zle "$@" ${${(M)funcstack[2]:#.autocomplete.fzf-completion}:+-w}
}
{
.autocomplete.fzf-completion "$@"
} always {
[[ -v functions[zle] ]] &&
unfunction zle
}
}
else
bindkey -M emacs $key[Tab] $tab_style
bindkey -M viins $key[Tab] $tab_style
fi
local backtab_style; zstyle -s :autocomplete:shift-tab: widget-style backtab_style ||
backtab_style=${tab_style:/menu-complete/reverse-menu-complete}
bindkey -M emacs $key[Shift-Tab] $backtab_style
bindkey -M viins $key[Shift-Tab] $backtab_style
if [[ $tab_style == *menu-* ]]; then
bindkey -M menuselect $key[Tab] menu-complete
else
bindkey -M menuselect $key[Tab] accept-line
fi
if [[ $backtab_style == *menu-* ]]; then
bindkey -M menuselect $key[Shift-Tab] reverse-menu-complete
else
bindkey -M menuselect -s $key[Shift-Tab] "$key[Tab]^_$key[Shift-Tab]"
fi
}
bindkey -M emacs $key[Control-Space] list-expand
bindkey -M vicmd $key[Control-Space] list-expand
bindkey -M viins $key[Control-Space] list-expand
bindkey -M emacs $key[Up] up-line-or-search
bindkey -M viins $key[Up] up-line-or-search
bindkey -M emacs $key[Alt-Up] history-search
bindkey -M emacs $key[PageUp] history-search
bindkey -M viins $key[PageUp] history-search
bindkey -M vicmd $key[Up] history-search
bindkey -M emacs $key[Down] down-line-or-select
bindkey -M viins $key[Down] down-line-or-select
bindkey -M emacs $key[Alt-Down] menu-select
bindkey -M emacs $key[PageDown] menu-select
bindkey -M viins $key[PageDown] menu-select
bindkey -M vicmd $key[Down] menu-select
bindkey -M menuselect $key[Return] .accept-line
bindkey -M menuselect $key[Control-Space] accept-and-hold
bindkey -M menuselect $key[Alt-Up] vi-backward-blank-word
bindkey -M menuselect $key[Alt-Down] vi-forward-blank-word
bindkey -M menuselect $key[PageUp] backward-word
bindkey -M menuselect $key[PageDown] forward-word
bindkey -M menuselect $key[Home] beginning-of-history
bindkey -M menuselect $key[End] end-of-history
bindkey -M menuselect '^?' .backward-delete-char
bindkey -M menuselect '^H' .backward-delete-char
bindkey -M menuselect '^[f' .forward-word
bindkey -M menuselect '^[F' .forward-word
bindkey -M menuselect '^[b' .backward-word
bindkey -M menuselect '^[B' .backward-word
bindkey -M menuselect '^A' .beginning-of-line
bindkey -M menuselect '^E' .end-of-line