This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
forked from boomker/rime-fast-xhup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrime.lua
147 lines (116 loc) · 4.95 KB
/
rime.lua
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---@diagnostic disable: lowercase-global
--[[
librime-lua 样例
调用方法:
在配方文件中作如下修改:
```
engine:
...
translators:
...
- lua_translator@lua_function3
- lua_translator@lua_function4
...
filters:
...
- lua_filter@lua_function1
- lua_filter@lua_function2
...
```
其中各 `lua_function` 为在本文件所定义变量名。
--]]
--[[
本文件的后面是若干个例子,按照由简单到复杂的顺序示例了 librime-lua 的用法。
每个例子都被组织在 `lua` 目录下的单独文件中,打开对应文件可看到实现和注解。
各例可使用 `require` 引入。
如:
```
foo = require("bar")
```
可认为是载入 `lua/bar.lua` 中的例子,并起名为 `foo`。
配方文件中的引用方法为:`...@foo`。
--]]
-- I. translators:
-- 本方案帮助菜单, `/oh`, `/help`
flypy_help_menu = require("flypy_help_menu")
-- datetime_translator: 将 `date`, `/wd`, `week`, `/wk`, `time`, `/wt`
-- 翻译为当前日期, 星期, 时间
date_time = require("date_time")
-- datetime_translator = date_time.translator
-- lunar_translator: 将 `/nl`, 翻译成农历
chinese_lunar = require("chinese_lunar")
-- lunar_translator = lunar.translator
-- number_translator: 将 `/cn` + 阿拉伯数字 翻译为大小写汉字
-- 详见 `lua/number.lua`
chinese_number = require("chinese_number")
-- number_translator = number.translator
calc_translator = require("calculator")
-- 英文生词造词入词库, 输入串末尾跟']'
en_custom = require("en_custom")
-- word_custom_translator = en_custom.translator
-- LaTeX 公式输入, `/lt`触发
LaTex = require("laTex")
-- laTex_translator = laTex.translator
-- 最近输入历史, `/hs` 触发
commit_history = require("commit_history")
-- history_translator = commit_history.translator
-- ---------------------------------------------------------------
-- II. filters:
-- charset_filter: 滤除含 CJK 扩展汉字的候选项
-- charset_comment_filter: 为候选项加上其所属字符集的注释
-- 详见 `lua/charset.lua`
charset = require("charset")
-- charset_filter = charset.filter
-- charset_comment_hint = charset.comment_hint
emoji_reduce = require("reduce_emoji")
-- emoji_reduce_filter = emoji_reduce.filter
-- 适用于中文输入方案的中英文之间加空格
word_append_space = require("word_append_space")
-- cn_space_en_filter = word_append_space.filter
-- space_leader_word = word_append_space.processor
-- 适用于英文输入方案的英文单词之间加空格
engword_append_space = require("engword_append_space")
-- engword_append_space_processor = engword_append_space.processor
-- 英文单词支持首字母大写, 全大写等格式
engword_autocaps = require("word_autocaps")
-- word_autocaps_filter = engword_autocaps.filter
-- word_autocaps_translator = engword_autocaps.translator
easy_en = require("easy_en")
-- easy_en_translator = easy_en.translator
-- easy_en_filter = easy_en.filter
-- 单字和二字词 全码顶屏(自动上屏)
word_autocommit = require("word_autocommit")
-- word_autocommit_processor = word_autocommit.processor
-- word_autocommit_translator = word_autocommit.translator
-- word_autocommit_filter = word_autocommit.filter
-- 词条置顶, 支持自定义编码(效果等同于 `custom_phrase`)
pin_word = require("pin_word")
-- pin_word_filter = pin_word.filter
-- pin_word_translator = pin_word.translator
-- pin_word_processor = pin_word.processor
-- 强制删词, 隐藏词组
cold_word_drop = require("cold_word_drop")
-- cold_word_drop_filter = cold_word_drop.filter
-- cold_word_drop_processor = cold_word_drop.processor
-- 音码优化 fixed
fly_fixed = require("fly_fixed")
-- fly_fixed_filter = fly_fixed.filter
-- ---------------------------------------------------------------
-- III. processors:
-- 以词定字
select_char = require("select_char")
-- select_char_processor = select_char.processor
-- 符号配对
pair_symbols = require("pair_symbols")
-- pair_symbols_processor = pair_symbols.processor
-- 快捷启动/切换应用, 如 `/jj` 触发; `/fj`: 快捷指令
launcher = require("launcher")
-- launcher_processor = launcher.processor
-- launcher_translator = launcher.translator
-- launcher_filter = launcher.filter
-- 成语短句优先, 'ctrl + 0' 触发
idiom_expand = require("idiom_abbr_expand")
-- idiom_expand_processor = idiom_expand.processor
flypy_switcher = require("flypy_switcher")
-- flypy_switch_processor = flypy_switcher.processor
-- flypy_switch_translator = flypy_switcher.translator