Giter Club home page Giter Club logo

xkbswitch.nvim's Introduction

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
use 'ivanesmantovich/xkbswitch.nvim'
  • Lazy (~/.config/nvim/lua/plugins/xkbswitch.lua)
return { 
    {'ivanesmantovich/xkbswitch.nvim'} 
}
  • Dein
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
use 'ivanesmantovich/xkbswitch.nvim'
  • Lazy (~/.config/nvim/lua/plugins/xkbswitch.lua)
return { 
    {'ivanesmantovich/xkbswitch.nvim'} 
}
  • Dein
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
use 'ivanesmantovich/xkbswitch.nvim'
  • Lazy (~/.config/nvim/lua/plugins/xkbswitch.lua)
return { 
    {'ivanesmantovich/xkbswitch.nvim'} 
}
  • Dein
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

xkbswitch.nvim's People

Contributors

dkaysin avatar ivanesmantovich avatar nikitat0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

xkbswitch.nvim's Issues

ru+phonetic_mac russian layout

Привет!

Плагин не работает на раскладке ru+phonetic_mac

OS: Pop!_OS 22.04 LTS x86_64
Kernel: Linux 6.2.6-76060206-generic
Shell: fish 3.6.1
DE: GNOME 42.5
WM: Mutter

NVIM v0.8.3
Подключение плагина:

│   use {
│     'ivanesmantovich/xkbswitch.nvim',
│     config = function()
│       require('xkbswitch').setup()
│     end
│   }

Перехожу в insert mode, переключаю раскладку на русскую, возвращаюсь в normal mode, раскладка остается русской.

g3kb-switch -n работает.

❯ g3kb-switch -l
us
ru+phonetic_mac
❯ ls -al /usr/local/lib/
total 132
drwxr-xr-x  3 root root  4096 Apr 14 10:23 ./
drwxr-xr-x 10 root root  4096 Mar  8 20:38 ../
-rwxrwxr-x  1 sts  sts  21832 Dec  4 16:19 libg3kbswitch.so*
lrwxrwxrwx  1 root root    17 Dec  4 17:49 libxkbswitch.so -> libxkbswitch.so.1*
lrwxrwxrwx  1 root root    21 Dec  4 17:49 libxkbswitch.so.1 -> libxkbswitch.so.1.8.5*
-rwxrwxr-x  1 sts  sts  94544 Dec  4 17:49 libxkbswitch.so.1.8.5*
drwxr-xr-x  3 root root  4096 Mar  8 20:38 python3.10/

FocusLost, FocusGained strange behavior

When I switch from nvim to KDE application with non US layout and switch back, Insert mode uses this non US layout even if it was US before switch to other app. This is misbehavior and I had to comment out FocusGained and FocusLost events in autocmd. Is this logic really needed and works as intended?

MacOS: english layout not found error

On my mac the US layout has a name
com.apple.keylayout.US.

And i get the following error on neovim start:

Error detected while processing /Users/Emptyfruit/.config/nvim/after/plugin/xkb-switch.lua:
E5113: Error while calling lua chunk: .../site/pack/packer/start/xkbswitch.nvim/lua/xkbswitch.lua:52: (xkbswitch.lua) Error occured: could not find the English layout. Check your layout list. (xkb-switch -l / issw -l / g3kb-switch -l)
stack traceback:

MacOS: 12.6.3
Neovim: 0.8.3
issw: 0.3

Remember used language per buffer

I tried out this plugin, and it only works for 1 instance of Neovim. Furthermore, the language persists between buffers. If multiple buffers/instances will be supported, then this plugin will deserve an ultimate status.

Suggestions for MacOS version

Hi! Thank you for making NeoVim alternative of the original xkbswitch. Love to see people making more and more lua stuff out there.

I tried your plugin, and it didn't work for me, so I decided to give you a couple of suggestions.

When you build vovkasm/input-source-switcher on MacOS you get libInputSourceSwitcher.dylib and issw. That issw binary is basically xkb-switch. It also has -l option, which produces the following on my machine:

com.apple.keylayout.ABC
com.apple.keylayout.Russian

There was also a change on recent MacOS versions on Apple Silicon Macs, which changed permissions for /usr/local/lib and /usr/local/bin. I don't want to use sudo, so I put libs and bins into another directory. I think people do the same, but I am not sure. Anyway, it would be great to have an ability to change default paths.

In short, my suggestions are:

  • add ability to use issw
  • improve US layout finder
  • add ability to change default paths

unclosed if statement

looks like you have an extra space in the else if statement in the latest fix ( # 4 )
see

else if string.find(value, '.US$') then

error log:

....local/share/nvim/lazy/lazy.nvim/lua/lazy/core/cache.lua:172: .../.local/share/nvim/lazy/xkbswitch.nvim/lua/xkbswitch.lua:123: 'end' expected (to close 'for' at line 45) near '<eof>'

# stacktrace:
  - ~/.config/nvim/lua/config/lazy.lua:9
  - ~/.config/nvim/init.lua:2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.