Do you have more than one keyboard layout and constantly switching back to English just to be able to move?
Stop it, get some help!
With xkbswitch.nvim you can write comments/notes/documents in your language of choice, press Esc
to enter Normal mode and instantly be ready to make your next move.
Plugin saves your actual layout before switching to English. The next time you enter Insert mode you will have your last saved layout.
It also works with focus. When Neovim loses focus plugin switches your layout to the last saved one. When Neovim gets focus plugin saves your layout, which you could've changed in another window and switches to English only if you need it. (Logic)
Now you need to switch your layout only when you need to type something in a different language! That's the way it always should have been.
macOS
- Install input-source-switcher
git clone https://github.com/vovkasm/input-source-switcher.git
cd input-source-switcher
mkdir build && cd build
brew install cmake
cmake ..
make
sudo make install
- Install this plugin
- Packer
use 'ivanesmantovich/xkbswitch.nvim'
- Dein
call dein#add('ivanesmantovich/xkbswitch.nvim')
- Add the setup line to your config
require('xkbswitch').setup()
Linux / Unix (X.org / Wayland)
- Install package
libxkbfile-dev
(orlibxkbfile-devel
if you use Fedora) - Install xkb-switch
git clone https://github.com/grwlf/xkb-switch.git
cd xkb-switch
mkdir build && cd build
cmake ..
make
sudo make install
sudo ldconfig
- Install this plugin
- Packer
use 'ivanesmantovich/xkbswitch.nvim'
- Dein
call dein#add('ivanesmantovich/xkbswitch.nvim')
- Add the setup line to your config
require('xkbswitch').setup()
GNOME 3 or 4 (g3kb-switch)
- Install
libglib2.0-dev
package (orglib2-devel
if you use Fedora) - Install g3kb-switch and the extension.
git clone https://github.com/lyokha/g3kb-switch.git
cd g3kb-switch
mkdir build && cd build
cmake ..
make
sudo make install
cd ../extension
make install # no sudo required!
- Install this plugin
- Packer
use 'ivanesmantovich/xkbswitch.nvim'
- Dein
call dein#add('ivanesmantovich/xkbswitch.nvim')
- Add the setup line to your config
require('xkbswitch').setup()
With Tmux
If you use Neovim inside of Tmux add this line to your .tmux.conf
set -g focus-events on
About
This plugin uses autocommands to 'listen' when you are entering and exiting Insert mode, or when Neovim gets or loses focus, and libcalls to change your layout.
- When leaving Insert Mode:
- Save the current layout
- Switch to the US layout
- When entering Insert Mode:
- Switch to the previously saved layout
- When Neovim gets focus:
- Save the current layout
- Switch to the US layout if Normal Mode or Visual Mode is the current mode
- When Neovim loses focus:
- Switch to the previously saved layout