Skip to content

teto/rikai.nvim

Repository files navigation

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 recommand 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.

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

How to use ?

There are no default keymaps so you need to set one

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.

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

Highlights used are visible in plugin/rikai.lua:

  • RikaiHighlightWordGroup
  • RikaiProperNoun
  • RikaiCurrentToken

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.

How to get the various dictionaries used by rikai.nvim ?

Run :Rikai download.

Related software

About

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

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors