forked from z-shell/zgdbm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rime-init
51 lines (48 loc) · 1.8 KB
/
rime-init
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
local dir shared_data_dir user_data_dir log_dir distribution_name distribution_code_name distribution_version app_name
local -i min_log_level
zstyle -a ':rime:traits' shared-data-dir shared_data_dir ||
for dir in {${PREIFX:-${SHELL%/*/*}}{,/usr}/share,/sdcard}/rime-data; do
[[ -d $dir ]] &&
shared_data_dir=$dir
done
zstyle -a ':rime:traits' user-data-dir user_data_dir ||
for dir in $HOME/.config/ibus/rime $HOME/.local/share/fcitx5/rime $HOME/.config/fcitx/rime /sdcard/rime; do
[[ -d $dir ]] &&
user_data_dir=$dir
done
zstyle -s ':rime:traits' log-dir log_dir ||
log_dir=${TMPPREFIX:-/tmp/zsh}/rime
zstyle -s ':rime:traits' distribution-name distribution_name ||
distribution_name=Rime
zstyle -s ':rime:traits' distribution-code-name distribution_code_name ||
distribution_code_name=zsh-rime
zstyle -s ':rime:traits' distribution-version distribution_version ||
distribution_version=0.0.1
zstyle -s ':rime:traits' app-name app_name ||
app_name=rime.zsh-rime
zstyle -s ':rime:traits' min-log-level min_log_level ||
min_log_level=3
local -A traits=(
[shared_data_dir]=$shared_data_dir
[user_data_dir]=$user_data_dir
[log_dir]=$log_dir
[distribution_name]=$distribution_name
[distribution_code_name]=$distribution_code_name
[distribution_version]=$distribution_version
[app_name]=$app_name
[min_log_level]=$min_log_level
)
mkdir -p $traits[log_dir]
rime init ${(kv)traits} &&
rime createSession rime_session_id &&
rime getCurrentSchema $rime_session_id rime_schema_id &&
rime getSchemaList $rime_schema_list
autoload -Uz rime-complete &&
zle -C rime-complete expand-or-complete rime-complete
autoload -Uz rime-next-schema &&
zle -N rime-next-schema
autoload -Uz rime-previous-schema &&
zle -N rime-previous-schema
autoload -Uz rime-ime &&
zle -N rime-ime
# ex: filetype=zsh