https://github.com/mrsobakin/multilayout.nvim
⌨️ Making vim friendly to alternative keyboard layouts
https://github.com/mrsobakin/multilayout.nvim
keyboard-layouts langmap multiple-languages multiple-layouts neovim neovim-plugin nvim nvim-plugin
Last synced: about 1 month ago
JSON representation
⌨️ Making vim friendly to alternative keyboard layouts
- Host: GitHub
- URL: https://github.com/mrsobakin/multilayout.nvim
- Owner: mrsobakin
- License: gpl-3.0
- Created: 2023-11-06T18:38:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-27T20:45:43.000Z (about 2 months ago)
- Last Synced: 2025-04-13T11:15:08.930Z (about 1 month ago)
- Topics: keyboard-layouts, langmap, multiple-languages, multiple-layouts, neovim, neovim-plugin, nvim, nvim-plugin
- Language: Lua
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ⌨️ multilayout.nvim
Write your КуМир code blazingly fast!
## 🤔 What this plugin does?
This plugin aims to fix some common problems that occur for users with multiple keyboard layouts. It teaches vim to understand alternative layouts and automatically convert between them and the standard qwerty (or any other layout if you want!).
You won't need to think about switching layouts anymore: for example, if you write in Russian, you can type `сшц` and it will be automatically converted into `ciw`. This also works for commands! If you have built muscle memory for saving files via `:w`, you won't need to check which language you're typing in! Just write `:ц` and vim will understand what you mean.
## 🛠️ Installation & Configuration
Add the plugin using your preferred manager:
```lua
-- Using lazy.nvim
require("lazy").setup({{ "mrsobakin/multilayout.nvim", opts = {
layouts = {
ru = {
-- Names of this layout, as `libukb` reports.
names = { "Russian" },
from = [[ёйцукенгшщзхъфывапролджэячсмитьбю.Ё"№;:?ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,]],
to = [[`qwertyuiop[]asdfghjkl;'zxcvbnm,./~@#$^&QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?]],
}
},
aliases = {
-- Maximum length of default commands aliases.
-- Increasing this value leads to longer startup times.
max_length = 2,
-- Extra commands that you want to alias.
-- They are aliased regardless of `max_length`.
extra = { "sort" },
},
-- Whether to use `libukb`. If this is set to false, `langmap`
-- won't automatically switch when your layout does.
use_libukb = false,
libukb_path = "/usr/local/lib/libukb.so",
}
}})
```If you want to use all **multilayout.nvim** features, you'll have to [install **ukb**](https://github.com/mrsobakin/ukb) and enable it.
## 💡 FAQ
### ⚖️ How does this plugin differ from the [**langmapper.nvim**](https://github.com/Wansmer/langmapper.nvim)?
**multilayout.nvim** is different from **langmapper.nvim** in almost every way! In fact, these plugins functionality does not intersect at all — quite the opposite, they complement each other.
While langmapper primarily focuses on translating mappings, multilayout translates motions and commands. In other words, while langmapper fixes your fzf's `ff`, multilayout fixes your `ciw`, `gcc` and `:w`'s.
I highly recommend you to check out langmapper if you want to have the complete `shift-alt`-less experience.
### 🤓☝️ How does this plugin work?
For converting motions, this plugin utilizes builtin vim functionality — `langmap`. In fact, this is why most of the motions work with **langmapper.nvim**: it's default config recommends you to configure the `langmap`. So, you can make most of the motions work even without plugins.
But **multilayout.nvim** does a bit more than that! First of all, it automatically generates the `langmap` for you. And second — this is where all the magic starts — it is able to switch the `langmap` depending on your current layout. Some characters are present on both layouts, but placed in different physical locations, which makes it impossible to use a single `langmap` for all layouts. **multilayout.nvim** solves that problem using [**ukb**](https://github.com/mrsobakin/ukb) — a universal keyboard utility. The coolest part is that it does not spawn any additional processes — libukb is loaded directly via LuaJIT's ffi.
Commands are translated using `cabbrev` aliases. You can read about them below in the special thanks section.
## 🔗 Special thanks to:
- [This](https://vim.fandom.com/wiki/Replace_a_builtin_command_using_cabbrev) ancient article about cabbrev
- **langmapper.nvim**, for the non-ascii character splitting function[*](https://github.com/Wansmer/langmapper.nvim/blob/main/lua/langmapper/helpers.lua)
- Dudes developing NeoVim for the awesome NeoVim API documentation