Skip to content
Kotoshu Kotoshu 言修

Documentation

Configuration

Kotoshu configuration: resolution order, KOTOSHU_* environment variables, XDG paths, dictionary types, and the personal dictionary.

One resolver, four sources, a fixed order — Kotoshu configuration is predictable by construction.

Settings

Resolution order

Every option resolves through the same chain, highest first. A CLI flag beats an environment variable, which beats a programmatic value, which beats the default.

CLI flags  →  ENV (KOTOSHU_*)  →  programmatic  →  defaults
highest                                            lowest

The programmatic layer is the global singleton reached through Kotoshu.configure:

Kotoshu.configure do |config|
config.default_language = "en"
config.max_suggestions = 5
config.dictionary_type = :hunspell
config.dictionary_path = "/usr/share/hunspell/en_US.dic"
end

After changing configuration, call Kotoshu.reset_spellchecker so the next check rebuilds with the new values.

Environment variables

Any variable below feeds the same resolver, so it applies to both the CLI and the library. The commonly used set:

VariablePurposeDefault
KOTOSHU_CACHE_PATHCache directory — dictionaries, frequency lists, models~/.cache/kotoshu
KOTOSHU_CONFIG_PATHUser config directory~/.config/kotoshu
KOTOSHU_DATA_PATHData directory — audit log~/.local/share/kotoshu
KOTOSHU_OFFLINENever download; use cached resources onlyunset (off)
KOTOSHU_NO_ONNXDisable the semantic path even when onnxruntime is installedunset
KOTOSHU_LANGUAGEConfigured languageen-US
KOTOSHU_DEFAULT_LANGUAGEFallback when detection is inconclusiveen
KOTOSHU_MAX_SUGGESTIONSSuggestions returned per word10
KOTOSHU_DICTIONARY_TYPEDictionary backendunix_words
KOTOSHU_PERSONAL_DICPersonal dictionary fileconfig dir + personal.dic

XDG paths

Kotoshu follows the XDG Base Directory specification. A KOTOSHU_*_PATH variable wins over the generic XDG_*_HOME, which wins over the default below.

ConcernDefault pathOverridden by
Dictionaries, frequency lists, ONNX models~/.cache/kotoshu/KOTOSHU_CACHE_PATH, XDG_CACHE_HOME
Personal dictionary, kotoshu.cfg~/.config/kotoshu/KOTOSHU_CONFIG_PATH, XDG_CONFIG_HOME
Audit log~/.local/share/kotoshu/audit.logKOTOSHU_DATA_PATH, XDG_DATA_HOME

Dictionary types

dictionary_type selects the backend the dictionary is loaded from:

TypeUse it when
:unix_wordsDefault. A flat system word list such as /usr/share/dict/words; Kotoshu detects the file when one exists
:plain_textYour own one-word-per-line list; requires dictionary_path
:customWords supplied in code via custom_words — tests and small embedded lists
:hunspellAn .aff/.dic pair with affix rules and compounding — the format kotoshu setup downloads; the .aff path is derived from the .dic path
:cspellReusing cspell-format dictionary files

Personal dictionary

Words you accept live in one personal dictionary, shared across languages, at ~/.config/kotoshu/personal.dic (or KOTOSHU_PERSONAL_DIC). The kotoshu personal subcommand manages it:

kotoshu personal add kotoshu
kotoshu personal import project-terms.txt   # one word per line
kotoshu personal list
kotoshu personal path

Where caches live and how they expire is covered in Caching.