Pure Lua migemo engine for LuaJIT. Converts romaji input into regex patterns that match hiragana, katakana, and kanji — enabling Japanese incremental search without switching input methods.
Ported from oguna/jsmigemo.
- LuaJIT (including Neovim's built-in LuaJIT)
A migemo compact dictionary is bundled, so no additional setup is needed.
local migemo = require "luamigemo"
-- Uses the bundled dictionary and PCRE regex by default
local pattern = migemo.query("kensaku")
-- => PCRE regex matching 検索, けんさく, ケンサク, etc.Pass an rxop table to query() to change the regex dialect:
local migemo = require "luamigemo"
-- Use Vim regex dialect
local pattern = migemo.query("tokyo", migemo.RXOP_VIM)You can use a different dictionary by passing a path to migemo.get():
local migemo = require "luamigemo"
-- Use a custom dict (e.g., the larger GPL dict from migemo-compact-dict-latest)
local m = migemo.get("/path/to/migemo-compact-dict")
local pattern = m:query("kensaku")The larger GPL-licensed dictionary is available from oguna/migemo-compact-dict-latest. It is derived from SKK-JISYO.L and has more entries than the bundled BSD dictionary.
| Constant | Description |
|---|---|
RXOP_PCRE |
PCRE syntax (for ripgrep, etc.) |
RXOP_VIM |
Vim regex syntax (for vim.regex()) |
In Neovim, run :checkhealth luamigemo to verify the dictionary and
LuaJIT environment.
| Module | Description |
|---|---|
luamigemo |
Main API with singleton management |
luamigemo.compact_dictionary |
Binary dictionary reader (jsmigemo format) |
luamigemo.louds_trie |
LOUDS-encoded trie |
luamigemo.bit_vector |
Succinct bit vector with rank/select |
luamigemo.romaji_processor |
Romaji to hiragana with predictive conversion |
luamigemo.ternary_regex_generator |
Regex pattern builder |
luamigemo.character_converter |
Full/half-width and hiragana/katakana conversion |
{ "delphinus/luamigemo", version = "*" }luarocks install luamigemoClone this repository and add lua/ to your package.path:
git clone https://github.com/delphinus/luamigemo.gitpackage.path = "/path/to/luamigemo/lua/?.lua;/path/to/luamigemo/lua/?/init.lua;" .. package.pathThe bundled dictionary (dict/migemo-compact-dict) is compiled from
yet-another-migemo-dict by jsmigemo. It is licensed under the
BSD 3-Clause License (see dict/LICENSE).
Pushing a tag matching v* triggers a GitHub Actions workflow that
automatically publishes the package to LuaRocks.
git tag v1.0.0
git push origin v1.0.0MIT License. See LICENSE for details.
- oguna/jsmigemo — original TypeScript implementation
- [oguna/yet-another-migemo-dict][] — dictionary data (BSD 3-Clause)
- koron/cmigemo — C/Migemo
- migemo — original concept by Satoru Takabayashi