From 6fc7f49449cb237e1aa37eb1025461fe3ea39589 Mon Sep 17 00:00:00 2001 From: seraphim <18ycm9tx@anonaddy.me> Date: Thu, 27 Aug 2026 11:50:43 +0700 Subject: . --- .config/vis/plugins/ru-langmap.lua | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .config/vis/plugins/ru-langmap.lua (limited to '.config/vis/plugins/ru-langmap.lua') diff --git a/.config/vis/plugins/ru-langmap.lua b/.config/vis/plugins/ru-langmap.lua new file mode 100644 index 0000000..0a81e35 --- /dev/null +++ b/.config/vis/plugins/ru-langmap.lua @@ -0,0 +1,67 @@ +-- ru-langmap: use QWERTY motions while Russian layout is active, +-- and stop Ctrl/Alt+arrows / Shift+Enter from leaking into the buffer. +-- No upstream plugin exists for this, so this is a local one. + +local M = {} + +local function modes(...) + return { ... } +end + +-- terminal keys the editor has no bindings for +function M.stray_keys() + local nop = function() end + for _, mode in ipairs(modes(vis.modes.NORMAL, vis.modes.VISUAL, vis.modes.OPERATOR_PENDING)) do + vis:map(mode, "", "b") + vis:map(mode, "", "w") + vis:map(mode, "", "b") + vis:map(mode, "", "w") + vis:map(mode, "", "") + vis:map(mode, "", "") + vis:map(mode, "", "") + end + for _, mode in ipairs(modes(vis.modes.INSERT, vis.modes.REPLACE, vis.modes.PROMPT)) do + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", nop) + vis:map(mode, "", "") + end +end + +-- ЙЦУКЕН -> QWERTY for modal editing (insert mode stays untouched) +function M.langmap() + local ru_en = { + q="й", w="ц", e="у", r="к", t="е", y="н", u="г", i="ш", o="щ", p="з", + ["["]="х", ["]"]="ъ", + a="ф", s="ы", d="в", f="а", g="п", h="р", j="о", k="л", l="д", + [";"]="ж", ["'"]="э", + z="я", x="ч", c="с", v="м", b="и", n="т", m="ь", + [","]="б", ["."]="ю", + } + local upper_ru = { + Й="Q", Ц="W", У="E", К="R", Е="T", Н="Y", Г="U", Ш="I", Щ="O", З="P", + Х="[", Ъ="]", + Ф="A", Ы="S", В="D", А="F", П="G", Р="H", О="J", Л="K", Д="L", + Ж=";", Э="'", + Я="Z", Ч="X", С="C", М="V", И="B", Т="N", Ь="M", + Б=",", Ю=".", + } + for _, mode in ipairs(modes(vis.modes.NORMAL, vis.modes.VISUAL, vis.modes.OPERATOR_PENDING)) do + for en, ru in pairs(ru_en) do + vis:map(mode, ru, en) + end + for ru, en in pairs(upper_ru) do + vis:map(mode, ru, en) + end + end +end + +vis.events.subscribe(vis.events.INIT, function() + M.stray_keys() + M.langmap() +end) + +return M -- cgit v1.2.3