Welcome to the librime-lua wiki!
Installation
weasel
Prepare the compiled file (or the latest artifact in actions).
Extract
rime-xxxx-Windows.7z/dist/lib/rime.dllfile and overwrite it to therime.dllfile under the weasel installation directory.
Usage
Create
PATH_TO_RIME_USER_DATA_DIR/rime.lua:luafunction date_translator(input, seg) if (input == "date") then --- Candidate(type, start, end, text, comment) yield(Candidate("date", seg.start, seg._end, os.date("%Y年%m月%d日"), " 日期")) 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 endMore sample: rime.lua
Documentation: wiki
Reference Lua functions in your schema:
yamlengine: ... translators: ... - lua_translator@date_translator - lua_translator@other_lua_function1 ... filters: ... - lua_filter@single_char_first_filter - lua_filter@other_lua_function2Deploy & try
Build
Build dependencies
- librime >= 1.5.0
- LuaJIT 2 / Lua 5.1 / Lua 5.2 / Lua 5.3 / Lua 5.4
Instructions
Prepare source code
Move the source to the
pluginsdirectory of librime:mv librime-lua $PATH_TO_RIME_SOURCE/plugins/luaOr you can use the
install-plugins.shscript to automatically fetch librime-lua:cd $PATH_TO_RIME_SOURCE bash install-plugins.sh hchunhui/librime-luaInstall dependencies
Install development files of Lua:
# For Debian/Ubuntu: sudo apt install liblua5.3-dev # or libluajit-5.1-devThe build system will use
pkg-configto search Lua.The build system also supports building Lua from source in the
thirdpartydirectory. Thethirdpartydirectory can be downloaded using the following commands:cd $PATH_TO_RIME_SOURCE/plugins/lua git clone https://github.com/hchunhui/librime-lua.git -b thirdparty --depth=1 thirdpartyBuild
Follow the librime's build instructions.
# On Linux, merged build make merged-plugins sudo make installFor more information on RIME plugins, see here.