diff --git a/config-sync/.config/ibus/rime/luna_pinyin.custom.yaml b/config-sync/.config/ibus/rime/luna_pinyin.custom.yaml index 9ddfb2f..b66f04d 100644 --- a/config-sync/.config/ibus/rime/luna_pinyin.custom.yaml +++ b/config-sync/.config/ibus/rime/luna_pinyin.custom.yaml @@ -2,4 +2,6 @@ # 文件中“patch:”应只存在一个,若已存在只需粘贴后面的代码 # 此文件用于修改特定输入方案,把上方的luna_pinyin改为其它输入方案名即可完成对其它输入方案的修改 patch: - "translator/dictionary": extended #词典名字可自定义,与下方文件名保持一致即可 \ No newline at end of file + "translator/dictionary": extended #词典名字可自定义,与下方文件名保持一致即可 + 'engine/translators/+': + - lua_translator@date_translator \ No newline at end of file diff --git a/config-sync/.config/ibus/rime/rime.lua b/config-sync/.config/ibus/rime/rime.lua new file mode 100644 index 0000000..920c1ae --- /dev/null +++ b/config-sync/.config/ibus/rime/rime.lua @@ -0,0 +1,31 @@ +function date_translator(input, seg) + if (input == "dd") then + --- Candidate(type, start, end, text, comment) + yield(Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d"), "")) + yield(Candidate("date", seg.start, seg._end, os.date("%Y年%m月%d日"), "")) + end + if (input == "ww") then + arr = {"一","二","三","四","五","六"} + arr[0] = "日" + yield(Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d 星期"..arr[tonumber(os.date("%w"))]), "")) + end + if (input == "tt") then + yield(Candidate("date", seg.start, seg._end, os.date("%Y-%m-%d %H:%M:%S"), "")) + yield(Candidate("date", seg.start, seg._end, os.date("%H:%M:%S"), "")) + end + end + + --- 过滤器:单字在先 + function single_char_first_filter(input) + local l = {} + for cand in input:iter() do + if (utf8.len(cand.text) == 1) then + yield(cand) + else + table.insert(l, cand) + end + end + for i, cand in ipairs(l) do + yield(cand) + end + end \ No newline at end of file