Skip to content

ivanesmantovich/xkbswitch.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Logo

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

  1. 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
  1. Install this plugin
Packer Lazy (~/.config/nvim/lua/plugins/xkbswitch.lua) Dein
use 'ivanesmantovich/xkbswitch.nvim'
return { 
    {'ivanesmantovich/xkbswitch.nvim'} 
}
call dein#add('ivanesmantovich/xkbswitch.nvim')
  1. Add the setup line to your config
require('xkbswitch').setup()

Linux / Unix (X.org / Wayland)

  1. Install package libxkbfile-dev (or libxkbfile-devel if you use Fedora)
  2. 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
  1. Install this plugin
Packer Lazy (~/.config/nvim/lua/plugins/xkbswitch.lua) Dein
use 'ivanesmantovich/xkbswitch.nvim'
return { 
    {'ivanesmantovich/xkbswitch.nvim'} 
}
call dein#add('ivanesmantovich/xkbswitch.nvim')
  1. Add the setup line to your config
require('xkbswitch').setup()

GNOME 3 or 4 (g3kb-switch)

  1. Install libglib2.0-dev package (or glib2-devel if you use Fedora)
  2. 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!
  1. Install this plugin
Packer Lazy (~/.config/nvim/lua/plugins/xkbswitch.lua) Dein
use 'ivanesmantovich/xkbswitch.nvim'
return { 
    {'ivanesmantovich/xkbswitch.nvim'} 
}
call dein#add('ivanesmantovich/xkbswitch.nvim')
  1. 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:
  1. Save the current layout
  2. Switch to the US layout
  • When entering Insert Mode:
  1. Switch to the previously saved layout
  • When Neovim gets focus:
  1. Save the current layout
  2. Switch to the US layout if Normal Mode or Visual Mode is the current mode
  • When Neovim loses focus:
  1. Switch to the previously saved layout

About

Smart automatic keyboard layout switching in 110 LOC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages