2023-05-08 10:42:21 +02:00
|
|
|
|
-- Rime Lua 扩展 https://github.com/hchunhui/librime-lua
|
|
|
|
|
-- 文档 https://github.com/hchunhui/librime-lua/wiki/Scripting
|
|
|
|
|
|
2023-08-06 12:37:28 +02:00
|
|
|
|
-- processors:
|
2023-05-16 16:21:36 +02:00
|
|
|
|
|
2023-12-08 15:40:51 +01:00
|
|
|
|
-- 以词定字,可在 default.yaml → key_binder 下配置快捷键,默认为左右中括号 [ ]
|
2023-05-08 10:42:21 +02:00
|
|
|
|
select_character = require("select_character")
|
2023-05-16 16:21:36 +02:00
|
|
|
|
|
2024-01-29 11:51:45 +01:00
|
|
|
|
-- 让写在 alphabet 中的某标点自动上屏,可在方案中配置标点
|
|
|
|
|
auto_commit_single_punct = require("auto_commit_single_punct")
|
|
|
|
|
|
2023-08-06 12:37:28 +02:00
|
|
|
|
-- translators:
|
|
|
|
|
|
2023-06-07 11:47:19 +02:00
|
|
|
|
-- 日期时间,可在方案中配置触发关键字。
|
2023-05-08 10:42:21 +02:00
|
|
|
|
date_translator = require("date_translator")
|
2023-05-16 16:21:36 +02:00
|
|
|
|
|
2024-01-02 15:25:13 +01:00
|
|
|
|
-- 农历,可在方案中配置触发关键字。
|
|
|
|
|
lunar = require("lunar")
|
|
|
|
|
|
2023-05-16 16:21:36 +02:00
|
|
|
|
-- Unicode,U 开头
|
2023-05-08 10:42:21 +02:00
|
|
|
|
unicode = require("unicode")
|
2023-05-16 16:21:36 +02:00
|
|
|
|
|
|
|
|
|
-- 数字、人民币大写,R 开头
|
|
|
|
|
number_translator = require("number_translator")
|
|
|
|
|
|
2023-08-06 12:37:28 +02:00
|
|
|
|
-- filters:
|
|
|
|
|
|
|
|
|
|
-- 错音错字提示
|
2023-12-08 15:40:51 +01:00
|
|
|
|
-- 关闭此 Lua 时,同时需要关闭 translator/spelling_hints,否则 comment 里都是拼音
|
2023-08-06 12:37:28 +02:00
|
|
|
|
corrector = require("corrector")
|
|
|
|
|
|
|
|
|
|
-- v 模式 symbols 优先(全拼)
|
|
|
|
|
v_filter = require("v_filter")
|
|
|
|
|
|
2023-05-30 16:06:38 +02:00
|
|
|
|
-- 自动大写英文词汇
|
|
|
|
|
autocap_filter = require("autocap_filter")
|
2023-05-21 04:59:21 +02:00
|
|
|
|
|
2023-12-08 15:40:51 +01:00
|
|
|
|
-- 降低部分英语单词在候选项的位置,可在方案中配置要降低的模式和单词
|
2023-06-07 11:47:19 +02:00
|
|
|
|
reduce_english_filter = require("reduce_english_filter")
|
|
|
|
|
|
2024-01-29 11:51:45 +01:00
|
|
|
|
-- 辅码,https://github.com/mirtlecn/rime-radical-pinyin/blob/master/search.lua.md
|
|
|
|
|
search = require("search")
|
|
|
|
|
|
2024-01-31 17:30:17 +01:00
|
|
|
|
-- 置顶候选项
|
2024-01-15 15:16:30 +01:00
|
|
|
|
pin_cand_filter = require("pin_cand_filter")
|
|
|
|
|
|
2023-06-29 14:25:04 +02:00
|
|
|
|
-- 长词优先(全拼)
|
|
|
|
|
long_word_filter = require("long_word_filter")
|
|
|
|
|
|
2024-02-05 17:29:51 +01:00
|
|
|
|
-- 默认未启用:
|
|
|
|
|
|
2023-06-07 11:47:19 +02:00
|
|
|
|
-- 中英混输词条自动空格
|
|
|
|
|
-- 在 engine/filters 增加 - lua_filter@cn_en_spacer
|
|
|
|
|
cn_en_spacer = require("cn_en_spacer")
|
|
|
|
|
|
2023-09-28 17:51:24 +02:00
|
|
|
|
-- 英文词条上屏自动空格
|
|
|
|
|
-- 在 engine/filters 增加 - lua_filter@en_spacer
|
|
|
|
|
en_spacer = require("en_spacer")
|
|
|
|
|
|
2023-09-28 18:21:41 +02:00
|
|
|
|
-- 九宫格,将输入框的数字转为对应的拼音或英文,iRime 用,Hamster 不需要。
|
2023-05-21 04:59:21 +02:00
|
|
|
|
-- 在 engine/filters 增加 - lua_filter@t9_preedit
|
2023-05-16 16:21:36 +02:00
|
|
|
|
t9_preedit = require("t9_preedit")
|
|
|
|
|
|
2023-08-06 12:37:28 +02:00
|
|
|
|
-- 根据是否在用户词典,在 comment 上加上一个星号 *
|
2023-05-21 04:59:21 +02:00
|
|
|
|
-- 在 engine/filters 增加 - lua_filter@is_in_user_dict
|
|
|
|
|
-- 在方案里写配置项:
|
|
|
|
|
-- is_in_user_dict: true 为输入过的内容加星号
|
2023-12-13 11:23:20 +01:00
|
|
|
|
-- is_in_user_dict: false 为未输入过的内容加星号
|
2023-05-08 10:42:21 +02:00
|
|
|
|
is_in_user_dict = require("is_in_user_dict")
|
2023-05-16 16:21:36 +02:00
|
|
|
|
|
2023-05-21 04:59:21 +02:00
|
|
|
|
-- 词条隐藏、降频
|
|
|
|
|
-- 在 engine/processors 增加 - lua_processor@cold_word_drop_processor
|
|
|
|
|
-- 在 engine/filters 增加 - lua_filter@cold_word_drop_filter
|
|
|
|
|
-- 在 key_binder 增加快捷键:
|
|
|
|
|
-- turn_down_cand: "Control+j" # 匹配当前输入码后隐藏指定的候选字词 或候选词条放到第四候选位置
|
|
|
|
|
-- drop_cand: "Control+d" # 强制删词, 无视输入的编码
|
2023-12-22 13:58:37 +01:00
|
|
|
|
-- get_record_filername() 函数中仅支持了 Windows、macOS、Linux
|
2023-05-08 10:42:21 +02:00
|
|
|
|
cold_word_drop_processor = require("cold_word_drop.processor")
|
|
|
|
|
cold_word_drop_filter = require("cold_word_drop.filter")
|
2024-02-02 15:50:12 +01:00
|
|
|
|
|
2024-02-05 17:29:51 +01:00
|
|
|
|
|
|
|
|
|
-- 暴力 GC
|
|
|
|
|
-- 详情 https://github.com/hchunhui/librime-lua/issues/307
|
|
|
|
|
-- 这样也不会导致卡顿,那就每次都调用一下吧,内存稳稳的
|
|
|
|
|
function force_gc()
|
2024-02-08 11:39:49 +01:00
|
|
|
|
-- collectgarbage()
|
|
|
|
|
collectgarbage("step")
|
2024-02-05 17:29:51 +01:00
|
|
|
|
end
|
|
|
|
|
|
2024-02-02 15:50:12 +01:00
|
|
|
|
-- 临时用的
|
|
|
|
|
function debug_checker(input, env)
|
2024-02-08 11:39:49 +01:00
|
|
|
|
for cand in input:iter() do
|
|
|
|
|
yield(ShadowCandidate(
|
|
|
|
|
cand,
|
|
|
|
|
cand.type,
|
|
|
|
|
cand.text,
|
|
|
|
|
env.engine.context.input .. " - " .. env.engine.context:get_preedit().text .. " - " .. cand.preedit
|
|
|
|
|
))
|
|
|
|
|
end
|
2024-02-02 15:50:12 +01:00
|
|
|
|
end
|