!refactor: Lua 模块引用方式变更 (#1094)

- 删除了 `rime.lua`
- 在方案中引用时添加 `*` 前缀
This commit is contained in:
wrvsrx
2024-12-06 00:11:43 +08:00
committed by GitHub
parent ed191350b2
commit aa505b7b2d
28 changed files with 219 additions and 260 deletions

View File

@@ -1,3 +1,6 @@
-- 中英混输词条自动空格
-- 在 engine/filters 增加 - lua_filter@cn_en_spacer
--
-- 为中英混输词条cn_en.dict.yaml自动空格
-- 示例:`VIP中P` → `VIP 中 P`
--

View File

@@ -1,3 +1,11 @@
-- 词条隐藏、降频
-- 在 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" # 强制删词, 无视输入的编码
-- get_record_filername() 函数中仅支持了 Windows、macOS、Linux
local filter = {}
function filter.init(env)

View File

@@ -1,3 +1,11 @@
-- 词条隐藏、降频
-- 在 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" # 强制删词, 无视输入的编码
-- get_record_filername() 函数中仅支持了 Windows、macOS、Linux
require("cold_word_drop.string")
require("cold_word_drop.metatable")
local processor = {}

View File

@@ -3,6 +3,8 @@
示例:「给予」的正确读音是 ji yu当用户输入 gei yu 时,在候选项的 comment 显示正确读音
示例:「按耐」的正确写法是「按捺」,当用户输入「按耐」时,在候选项的 comment 显示正确写法
关闭此 Lua 时,同时需要关闭 translator/spelling_hints否则 comment 里都是拼音
为了让这个 Lua 同时适配全拼与双拼,使用 `spelling_hints` 生成的 comment全拼拼音作为通用的判断条件。
感谢大佬@[Shewer Lu](https://github.com/shewer)提供的思路。

View File

@@ -1,4 +1,4 @@
-- 日期时间
-- 日期时间,可在方案中配置触发关键字。
-- 提高权重的原因:因为在方案中设置了大于 1 的 initial_quality导致 rq sj xq dt ts 产出的候选项在所有词语的最后。
local function yield_cand(seg, text)

12
lua/debuger.lua Normal file
View File

@@ -0,0 +1,12 @@
local function debuger(input, env)
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
end
return debuger

View File

@@ -1,3 +1,6 @@
-- 英文词条上屏自动添加空格
-- 在 engine/filters 的倒数第二个位置,增加 - lua_filter@en_spacer
--
-- 英文后,再输入英文单词(必须为候选项)自动添加空格
local F = {}

9
lua/force_gc.lua Normal file
View File

@@ -0,0 +1,9 @@
-- 暴力 GC
-- 详情 https://github.com/hchunhui/librime-lua/issues/307
-- 这样也不会导致卡顿,那就每次都调用一下吧,内存稳稳的
local function force_gc()
-- collectgarbage()
collectgarbage("step")
end
return force_gc

View File

@@ -1,6 +1,8 @@
-- 根据是否在用户词典,在结尾加上一个星号 *
-- is_in_user_dict: true 输入过的内容
-- is_in_user_dict: false 或不写 未输入过的内容
-- 根据是否在用户词典,在 comment 上加上一个星号 *
-- 在 engine/filters 增加 - lua_filter@is_in_user_dict
-- 在方案里写配置项:
-- is_in_user_dict: true 为输入过的内容加星号
-- is_in_user_dict: false 为未输入过的内容加星号
local M = {}

View File

@@ -2,6 +2,8 @@
Lua 阿拉伯数字转中文实现 https://blog.csdn.net/lp12345678910/article/details/121396243
农历功能复制自 https://github.com/boomker/rime-fast-xhup
--]]
--
-- 农历,可在方案中配置触发关键字。
-- 数字转中文:

View File

@@ -1,4 +1,4 @@
-- 降低部分英语单词在候选项的位置
-- 降低部分英语单词在候选项的位置,可在方案中配置要降低的模式和单词
-- https://dvel.me/posts/make-rime-en-better/#短单词置顶的问题
-- 感谢大佬 @[Shewer Lu](https://github.com/shewer) 指点
-- Mintimate 修改:

View File

@@ -1,3 +1,5 @@
-- 辅码https://github.com/mirtlecn/rime-radical-pinyin/blob/master/search.lua.md
--
-- Copyright (C) [Mirtle](https://github.com/mirtlecn)
-- License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
-- 使用说明:<https://github.com/mirtlecn/rime-radical-pinyin/blob/master/search.lua.md>

View File

@@ -1,6 +1,6 @@
-- 以词定字
-- 原脚本 https://github.com/BlindingDark/rime-lua-select-character
-- 删除了默认按键 [ ],和方括号翻页冲突,需要在 key_binder 下指定才能生效
-- 可在 default.yaml → key_binder 下配置快捷键,默认为左右中括号 [ ]
-- 20230526195910 不再错误地获取commit_text而是直接获取get_selected_candidate().text
-- 20240128141207 重写:将读取设置移动到 init 方法中;简化中文取字方法;预先判断候选存在与否,无候选取 input
-- 20240508111725 当候选字数为 1 时,快捷键使该字上屏

View File

@@ -1,3 +1,6 @@
-- 九宫格将输入框的数字转为对应的拼音或英文iRime 用Hamster 不需要。
-- 在 engine/filters 增加 - lua_filter@t9_preedit
--
-- 九宫格专用iRime 用,仓输入法不用
-- 拼写规则通过 xlit 转写: xlit/abcdefghijklmnopqrstuvwxyz/22233344455566677778889999/
-- 然后通过此 Lua 将输入框的数字转为对应的拼音或英文

View File

@@ -1,4 +1,4 @@
-- v 模式,单个字符优先
-- v 模式,单个字符优先(全拼)
-- 因为设置了英文翻译器的 initial_quality 大于 1导致输入「va」时候选项是「van vain …… ā á ǎ à」
-- 把候选项应改为「ā á ǎ à …… van vain」让单个字符的排在前面
-- 感谢改进 @[t123yh](https://github.com/t123yh) @[Shewer Lu](https://github.com/shewer)