Syntax-Aware Keyboard Layout Switching (SAKLS) plugin for Neovim!
When editing a file containing text in multiple languages, there is always the burden of manually switching keyboard layout. A notable example (which was actually the motivation behind this project) is writing TeX documents in a non-English language. While the text has to be typed in that other language, the formulae (in math mode) still have to be entered in English!
SAKLS project aims to eliminate this inconvenience by automatically switching keyboard layout based on the syntax information in the current window. SAKLS aims to become a large project, supporting many platforms and many text editors; sakls.nvim plugin is only a small fraction of the project, providing Neovim support.
- Automatic switching of the current keyboard layout upon a transition to a new syntax element in Vim buffer, which is when
- writing text and/or moving cursor in insert mode;
- entering or exiting insert mode.
- Layout switching algorithm is flexibly configured by a SAKLS schema (TODO insert link).
- Potential support for many platforms via selecting a suitable layout backend (TODO insert link) in SAKLS library.
- However, at this moment only xkb-switch layout backend is supported, which is for Unix platforms with X server.
- Potential support for many syntax providers (TODO insert link), like tree-sitter, or (perhaps) LSP.
- However, at this moment the only supported syntax provider is the provider based on native Vim syntax highlighting, called here
vimsyn.
- However, at this moment the only supported syntax provider is the provider based on native Vim syntax highlighting, called here
- Obtain SAKLS shared library by following instructions from SAKLS repository.
- Make sure that SAKLS library is compiled with your preferred layout backend (TODO insert link). Alternatively, obtain a suitable layout plugin (TODO insert link).
- Install
sakls.nvimplugin in Neovim with your favorite package manager. For example, with packer.nvim you would sayuse 'sharkov63/sakls.nvim'
First step is to initialize sakls.nvim by calling init function. For example:
local sakls = require 'sakls'
sakls.init {
sakls_lib = {
path = '/home/danila/workspace/sakls/sakls/build/lib/libSAKLS.so',
},
layout_backend = 'xkb-switch',
}