Switch back from IME after InsertLeave
. Powered by dbus.
- Vim (include other editors who have a vim emulator) is mulit-mode editor:
- insert mode
- normal mode
- ...
- IME is also multi-mode mostly:
- ASCII mode
- CJKV mode
- ...
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:
- no dependencies of GUI
- support remote machines: ssh, telnet, ...
- Vim passes user's input to IME by librime/dbus
- IME passes the result to Vim by librime/dbus
- Vim draw UI of Vim IME window
- When user
InsertLeave
, we close Vim IME window.
librime is a library for creating IME.
dbus is an inter process communication system. we can communicate with an external IME.
- fcitx5.nvim: for fcitx5
- fcitx5-ui.nvim: for fcitx5
- support more hotkeys
- same settings as IME for other windows
- call IME to switch back to ASCII mode when
InsertLeave
by CLI/dbus
Some IMEs provide a CLI program to switch mode.
- issw: for macOS
- macism: for macOS
- im-select: for macOS and Windows
ibus engine
: for ibusg3kb-switch
: for ibus, and provide a DLLxkb-switch
: for xim, and provide a DLLfcitx-remote
: for fcitx5
Some Vim plugins use CLI:
- nvim-auto-ime: only support macism
- im-select.nvim: support im-select, ibus, fcitx
- vim-xkbswitch: support g3kb-switch, xkb-switch and issw by their DLLs, where g3kb-switch utilizes dbus and is written in C
- fcitx.vim: support fcitx and fcitx5-rime. written in python
- This plugin: support
- fcitx5: with or without rime input schema
- ibus
- gnome-shell: you can get IME information from gnome-shell whatever you use which IME. You need unsafe-mode-menu to open unsafe mode in latest gnome-shell.
- g3kb-switch: or use it to bypass security prohibit.
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
Editor can provide a popup menu to let user select candidate. If user use Ctrl + P/N to select, input CJKV characters. Otherwise, input ASCII characters.
- more key pressing, the 10-th candidation need 10 times Ctrl + N
- ASCII characters cannot be near CJKV characters.
hi nihao
will completenihao
,hinihao
will completehinihao
. However, it shouldn't happen. Because:
中英文之間需要增加空格
-- 中文文案排版指北
We can create:
- a language server to support all editors which supports LSP. The editor will manage the popup menu according to LSP.
- an editor specific plugin.
- register a completion source of other editor plugins which manage the popup menu
- manage the popup menu by itself
- ds-pinyin-lsp: only support full pinyin.
- coc-rime: written in javascript
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
- vimIM: stop maintenance
- ZFVimIM: a rewrite of vimIM. It will disable most completion plugins when it is enabled.
# 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
:Rocks install ime.nvim
~/.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
For NixOS, export $GI_TYPELIB_PATH
in your shell profile to make
require'dbus_proxy'
work. Refer my
~/.bash_profile
.