Home

Awesome

ime.nvim

pre-commit.ci status github/workflow

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

luarocks

Switch back from IME after InsertLeave. Powered by dbus.

Introduction

Multi-mode IME

In insert mode, we can switch IME mode to input ASCII characters or CJKV characters. However, in other modes of Vim, only ASCII mode can work: Vim will not response any CJKV character. So we must switch back from IME after InsertLeave.

Currently, we have two schemes to realize it:

IME inside Vim

IME inside Vim

  1. Vim passes user's input to IME by librime/dbus
  2. IME passes the result to Vim by librime/dbus
  3. Vim draw UI of Vim IME window
  4. When user InsertLeave, we close Vim IME window.
librime

librime is a library for creating IME.

dbus

dbus is an inter process communication system. we can communicate with an external IME.

IME outside Vim

IME outside Vim

  1. call IME to switch back to ASCII mode when InsertLeave by CLI/dbus
CLI

Some IMEs provide a CLI program to switch mode.

Some Vim plugins use CLI:

dbus

In Gnome 41 and newer, the switcher will only work with G3kbSwitch Gnome Shell extension, because method org.gnome.Shell.Eval which was used in the original implementation of the switcher is now disabled for security reasons

-- g3kb-switch

single-mode IME

single-mode IME

<!-- markdownlint-disable MD033 -->

Editor can provide a popup menu to let user select candidate. If user use <kbd>Ctrl</kbd> + <kbd>P</kbd>/<kbd>N</kbd> to select, input CJKV characters. Otherwise, input ASCII characters.

<!-- markdownlint-enable MD033 -->

中英文之間需要增加空格

-- 中文文案排版指北

We can create:

LSP

coc.nvim

nvim-cmp

Manage popup menu by itself

Manage popup menu by itself will result in the conflict with other editor plugins which manage the popup menu. At the same time, you must enable one of them.

Sorry, you have to make the choice.

-- coc-snippets

Dependencies

# Ubuntu
sudo apt-get -y install libgirepository-1.0-1 libgirepository1.0-dev pkg-config
sudo apt-mark auto libgirepository1.0-dev pkg-config
# ArchLinux
sudo pacman -S libgirepository pkg-config
# Android Termux
apt-get -y install gobject-introspection pkg-config
# Nix
# use nix-shell to create a virtual environment then build

Install

rocks.nvim

Command style

:Rocks install ime.nvim

Declare style

~/.config/nvim/rocks.toml:

[plugins]
"ime.nvim" = "scm"

Then

:Rocks sync

or:

$ luarocks --lua-version 5.1 --local --tree ~/.local/share/nvim/rocks install ime.nvim
# ~/.local/share/nvim/rocks is the default rocks tree path
# you can change it according to your vim.g.rocks_nvim.rocks_path

Tips

if [[ -f /run/current-system/nixos-version ]]; then
  if [[ -f /the/path/lua/5.1/ime/get-GI_TYPELIB_PATH.nix ]]; then
    export GI_TYPELIB_PATH
    eval GI_TYPELIB_PATH="$(nix eval --impure -f ~/.local/share/lua/5.1/ime/get-GI_TYPELIB_PATH.nix)"
  fi
fi