A Neovim plugin that prevents unintended actions when typing in non-English keyboard layouts. Works across multiple environments (X11, Wayland, Windows, macOS) and provides immediate feedback when typing with a non-English layout.
- Lightweight and performant
- Cross-platform support (X11, Wayland, Windows, macOS)
- Prevents accidental commands in non-English layouts
- Minimal configuration required
- No external dependencies for most environments
- Neovim >= 0.8.0
- Environment-specific requirements:
- X11:
xset(usually pre-installed) - Wayland:
swaymsg(for Sway) orgdbus(for GNOME) - Windows: PowerShell (pre-installed)
- macOS: No additional requirements
- X11:
Using lazy.nvim:
{
"MatanyaP/keyboard-guard.nvim",
event = "VeryLazy",
opts = {
-- your configuration
}
}Using packer.nvim:
use {
'MatanyaP/keyboard-guard.nvim',
config = function()
require('keyboard_guard').setup({
-- your configuration
})
end
}require('keyboard_guard').setup({
notification = {
enabled = true, -- enable notifications
style = "minimal", -- "minimal" or "default"
message = "Please switch to English layout!",
},
modes = {
n = true, -- protect normal mode
i = false, -- don't protect insert mode
c = true, -- protect command mode
},
})Once installed and configured, the plugin works automatically:
- In normal mode: prevents executing commands when in non-English layout
- In command mode: prevents entering commands with non-English layout
- Shows notifications when attempting to type in protected modes with non-English layout
Debug commands:
:KGDebug " Show debug information about current layout
:KGStatus " Show current plugin statusThe plugin detects your current keyboard layout using native system commands and prevents potentially destructive actions when a non-English layout is active. It's designed to be lightweight and only loads what's necessary for your specific environment.
If you experience any issues:
- Run
:checkhealth keyboard-guardto verify your environment setup - Use
:KGDebugto get detailed information about the current state - Try setting
notification.style = "default"for better visibility during debugging - For WSL users: Make sure PowerShell is accessible from your WSL environment
Contributions are welcome! Please see our Contributing Guide for more details.
MIT
