im-switch.nvim automatically switches your input method (IM) in Neovim based on events (e.g. InsertLeave, InsertEnter).
It helps when you frequently switch between English and non-English IMs while coding.
- 🔄 Switch input method according to Neovim events
- 📦 No need to install other tools to switch input method like im-select
- 🖥️ Works on Windows/WSL2/macOS/Linux
| OS | Requirements |
|---|---|
| All OS | Neovim >= 0.10.0 |
| Linux | An input method framework (e.g., fcitx5, ibus) |
Note
The plugin automatically downloads the im-switch CLI binary during installation.
No manual setup is required for Windows/WSL2/macOS.
On Linux, the CLI supports fcitx5 and ibus natively, but you can also use custom commands for other frameworks.
Install the plugin with your preferred package manager.
{
"drop-stones/im-switch.nvim",
event = { "InsertEnter", "CmdlineEnter" },
opts = {
-- your configurations
}
}Note
The plugin only reacts to editing-mode transitions — InsertLeave/CmdlineLeave (and, in restore
mode, InsertEnter/InsertLeavePre) — so it is safe to load it as late as the first time you type.
Loading on InsertEnter and CmdlineEnter covers both insert and command-line input. You are free to
pick any other lazy-loading trigger that fits your workflow.
lazy.nvim downloads the im-switch CLI automatically on
install and update, so no build key is needed.
vim.pack (Neovim 0.12+)
vim.pack.add({ "https://github.com/drop-stones/im-switch.nvim" })
require("im-switch.build").setup()
require("im-switch").setup({
-- your configurations
})Note
vim.pack has no build step, so call require("im-switch.build").setup() yourself to download the
im-switch CLI. It downloads only when the CLI is missing
or outdated — otherwise it returns immediately without running any process — so it is safe to call on
every startup.
| Key | Type | Default | Description |
|---|---|---|---|
mode |
string |
"restore" |
IM switching mode |
Available modes:
"restore"(default) — Saves IM state per buffer onInsertLeaveand restores it onInsertEnter."fixed"— Always switches to the default IM. No save/restore.
| Key | Type | Required | Description |
|---|---|---|---|
macos.default_im |
string |
Yes | Default IM to switch to when leaving insert/cmdline mode |
require("im-switch").setup({
macos = {
default_im = "com.apple.keylayout.ABC",
},
})| Key | Type | Required | Description |
|---|---|---|---|
linux.default_im |
string |
Yes | Default IM to switch to when leaving insert/cmdline mode |
linux.get_im_command |
string[] |
No | Custom command to get current IM (takes priority over CLI if set) |
linux.set_im_command |
string[] |
No | Custom command to set IM (takes priority over CLI if set) |
require("im-switch").setup({
linux = {
default_im = "keyboard-us",
},
})Tip
If your IM framework is not supported by the im-switch CLI, you can use custom commands:
linux = {
default_im = "default",
get_im_command = { "my-im-tool", "get" },
set_im_command = { "my-im-tool", "set" },
}| Key | Type | Required | Description |
|---|---|---|---|
wsl2.server |
boolean |
No | Opt into the loopback IPC fast path (default: false) |
On WSL the plugin controls the Windows IME with no configuration required.
By default each switch runs im-switch.exe through WSL interop, which adds about 60 ms of process-startup latency.
Set wsl2.server = true to enable the loopback IPC fast path: a long-lived Windows daemon is started once and each
switch is forwarded to it over TCP (about 1–2 ms instead of 60 ms), with a transparent fallback to a direct call if the daemon is unreachable.
require("im-switch").setup({
wsl2 = {
server = true,
},
})Note
The fast path requires WSL2 mirrored networking mode (Windows 11 22H2+),
enabled in C:\Users\<user>\.wslconfig (run wsl --shutdown after editing):
[wsl2]
networkingMode=mirrored
[experimental]
hostAddressLoopback=trueNeovim cannot switch IM directly, so this plugin uses the im-switch CLI:
- Windows/WSL2: Toggles IME on/off via
im-switch ime on/off - macOS: Switches input source via
im-switch set <input_source_id> - Linux: Uses
im-switchCLI (fcitx5/ibus) or user-configured custom commands
The CLI binary is automatically downloaded from GitHub Releases during plugin installation.
| OS | Architecture |
|---|---|
| Windows/WSL2 | x86_64, aarch64 |
| macOS | x86_64, aarch64 |
| Linux | x86_64, aarch64 |
Run :checkhealth im-switch if you run into any issues.
This project is licensed under the MIT License - see the LICENSE file for details.