Skip to content

Repository files navigation

include_toc true

This plugin aims at providing offline translations either on-demand and/or automatically when hovering asian (japanese for now) characters.

The name is inspired by the great browser rikaitan plugin. 理解 ("rikai") translates to "understanding", "comprehension".

Here are some possibly outdated screenshots:

  • Popup for a kanji
image - popup for an expression, the current word is automatically highlighted on cursor movement image

How to install ?

If you are using nix, you can use the flake to add the vim plugin to your system. Dependencies are visible in the flake.nix. Similarly if you want to test it out, you can just enter the shell with nix develop.

On other systems, you must find a way to install these dependencies:

System Dependencies:

  • sudachi_rs as a tokenizer (ie., split words), use the full version
  • [unzip][unzip] to unpack dictionaries

Lua dependencies:

I recommend using the neovim package manager rocks.nvim since it automatically installs the lua dependencies.

:Rocks install rikai.nvim

Once the plugin is installed, you will need to download the Japanese dictionaries with :Rikai download (needed just once):

Tip

Popups are written in markdown, to improve the rendering I advise installing render-markdown-nvim though it remains optional.

How to configure ?

The plugin does not need any configuration: it works out of the box once installed. You can tweak its behavior via vim.g.rikai, see lua/rikai/config/default.lua for the available options.

Tip

Enable image preview if your terminal (for instance 'kitty') supports it with:

vim.g.rikai = {
  popup_options = {
    render_images = true,
  }
}

You will need to install snacks.nvim as well.

You can tweak the highlights starting with Rikai* as well.

Highlight groups

Highlights used are visible in plugin/rikai.lua:

  • RikaiHighlightWordGroup
  • RikaiProperNoun
  • RikaiCurrentToken

You can finally check your installation/configuration with :checkhealth rikai

How to use ?

Search dictionary

There are no default keymaps so you need to set one. For instance to search the dictionary for visual selection or character under cursor:

vim.keymap.set({'n', 'v'}, '<D-j>', function() vim.cmd([[ Rikai lookup ]]) end, { buffer = false, desc = 'Japanese lookup' })

You can also call :Rikai lookup 見 to see the translation.

Live highlighting

To enable a more rikaichamp/yomitan-like experience, run :Rikai live enable to enable automatic translation and highlighting of current token. It's experimental and not as polished as its inspiration though.

Roadmap

  • lux packaging
  • romaji to kana and vice-versa
  • let users customize display (support https://jpdb.io/)
  • add rikai translate

See wiki for more reference.

Related software

About

rikaitan for neovim, i.e., japanese translation integrated

Topics

Resources

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Contributors

Languages