Why I Built a Zero-Underline Vietnamese IME for Linux in Rust
Anyone who has used Linux in Vietnam knows the long-standing frustration of typing Vietnamese on desktop environments—especially with the widespread adoption of Wayland (GNOME, KDE Plasma, Hyprland, Sway).
Traditional Input Method Engines (IMEs) rely on a pre-edit buffer. While this works reasonably well on macOS or Windows, on Linux it often produces:
- Flickering Underlines: Every keystroke shows an underlined temporary word that interrupts code auto-completion in VS Code, Neovim, and terminal emulators.
- Clipboard Race Conditions: Many input methods simulate backspaces and paste transformed characters via the system clipboard, colliding with your actual clipboard history or password managers.
-
Broken English Words: When typing common English words containing Vietnamese key combinations (e.g.,
test,search,code), words often get mangled into unnatural accent marks unless manually disabled.
To fix these problems at the root, I built Viet+ (VietC): a modern, zero-latency, zero-underline Vietnamese IME written 100% in Rust.
⚡ The Architecture: Direct Virtual Keystroke Injection
Instead of hijacking the desktop text field with a pre-edit overlay, Viet+ operates directly at the device input layer:
[Hardware Keyboard]
│
▼
[Viet+ Engine (Rust)] ───► [Finite State Machine & Telex/VNI Rules]
│
▼ (Direct Unicode via /dev/uinput or wtype)
[Target Application: Terminal, Browser, IDE]
1. Zero Underline (No Pre-Edit Buffer)
Viet+ processes keystrokes in-flight. Characters appear directly in your active application as real Unicode text. No ghost underlines, no flickering text frames, and no disruption to IDE autocomplete dropdowns.
2. Intelligent English Auto-Restoration
A common nuisance when typing bilingual technical documents is accidentally turning English words into accented Vietnamese (e.g. typing as becoming á, or format becoming fórmat).
Viet+ embeds an intelligent trie-based dictionary check. If you type an English word pattern, the engine automatically rolls back the diacritics and restores clean English text without requiring you to constantly hit Ctrl + Space or switch modes.
Nguyeenx DDawng Khoa ➔ Nguyễn Đăng Khoa
Khoong cos gif quis ➔ Không có gì quí
search for the test ➔ search for the test (Auto-Restored!)
3. Wayland & X11 First-Class Support
Viet+ is designed for modern Wayland compositors:
-
Wayland: Native virtual keyboard protocol integration via
wtypeandwl-clipboard. -
X11: Seamless fallback using
xdotoolandX11key injection. - Hyprland / Sway / GNOME / KDE: Tested across leading tiling and desktop window managers.
🦀 Why Rust?
Input methods require predictable microsecond latency. Every key press must be intercepted, checked against grammar state machines, and re-emitted before the user's next keystroke lands.
By using Rust:
- Zero Garbage Collection: Predictable sub-millisecond response times.
- Safe Memory Concurrency: Safe IPC communication between background daemons and system trays.
- 100% Test Coverage: Viet+ includes 151 unit tests validating complex Telex, VNI, tone placement rules, and edge-case word combinations.
🚀 1-Command Installation
You can install Viet+ on Arch Linux, Fedora, Ubuntu, Debian, or openSUSE with a single command:
curl -fsSL https://raw.githubusercontent.com/vndangkhoa/vietc/main/install.sh | bash
Once installed, start the background daemon:
vietc &
Toggle between Vietnamese and English modes effortlessly using Ctrl + Space (customizable).
🔗 Check it Out on GitHub
Viet+ is 100% open-source under the MIT license. If you're running Linux and want a smooth, native typing experience without UI clutter:
⭐ GitHub Repository: https://github.com/vndangkhoa/vietc
Feedback, issues, and PRs are warmly welcome!
Top comments (0)