Closed IvanKarpov-1 closed 5 months ago
I looked at the other issues and saw that I need to add hack_get_keymap()
after calling setup()
so that the which-key does not contain Cyrillic.
Now the question of keyboard layouts for other languages remains.
Now the question of keyboard layouts for other languages remains.
To add another language, you need to add a new layout to layouts
(with all fields as in Russian layout), e.g:
require("langmapper").setup({
layouts = {
---@type table Fallback layout item. Name of key is a name of language
ru = { --[[layout preset]] },
fr = { --[[layout preset]] },
gr = { --[[layout preset]] },
},
})
Also, don't forget to set vim.opt.langmap
for the additional input method.
you need to add a new layout to
layouts
I did, but I kept getting errors, so I asked about it because I thought I was doing something wrong.
Errors:
I was able to fix it by setting hack_keymap
to false
. This seemed to fix the problem, but I haven't used Neovim long enough after that to try all the keyboard shortcuts I use, so I can't say for sure.
Now my settings look like this.
langmapper
configuration:
return {
"Wansmer/langmapper.nvim",
lazy = false,
priority = 1,
config = function()
local langmapper = require("langmapper")
langmapper.setup({
hack_keymap = false,
layouts = {
ua = {
id = "ua",
layout = "ФИСВУАПРШОЛДЬТЩЗЙКІЕГМЦЧНЯБЮЖЄХЇʼ,фисвуапршолдьтщзйкіегмцчнябюжєхї'.",
default_layout = [[ABCDEFGHIJKLMNOPQRSTUVWXYZ<>:"{}~?abcdefghijklmnopqrstuvwxyz,.;'[]`/]],
}
},
os = {
Linux = {
get_current_layout_id = function()
local cmd = "gsettings"
if vim.fn.executable(cmd) then
local output = vim.fn.system(
cmd .. " get org.gnome.desktop.input-sources mru-sources | sed -r \"s/\\S*\\s'([^']+).*/\\1/\""
)
return output
end
end,
},
},
})
langmapper.hack_get_keymap()
end,
}
options.lua:
local function escape(str)
local escape_chars = [[;,."|\]]
return vim.fn.escape(str, escape_chars)
end
local en = [[abcdefghijklmnopqrstuvwxyz,.;'[]`/]]
local ua = [[фисвуапршолдьтщзйкіегмцчнябюжєхї'.]]
local en_shift = [[ABCDEFGHIJKLMNOPQRSTUVWXYZ<>:"{}~?]]
local ua_shift = [[ФИСВУАПРШОЛДЬТЩЗЙКІЕГМЦЧНЯБЮЖЄХЇʼ,]]
vim.opt.langmap = vim.fn.join({ escape(ua_shift) .. ";" .. escape(en_shift), escape(ua) .. ";" .. escape(en) }, ",")
I also added require("langmapper").automapping({ global = true, buffer = true })
to the end of init.lua
.
As far as I understood, the README section on which-key contains code that should return English characters back to which-key. I have rewritten this code for myself, but still have Cyrillic in which-key.
How can I make sure that the which-key does not have Cyrillic characters?
Which-key output:
langmapper configuration:
Which-key configuration:
Also, I didn't quite understand how to set up mapping for other keyboard layouts other than ru.
I defined the
langmap
option to the layout I need and called thelangmapper
plugin simply aslangmapper.setup({})
and it seems to work.But in the standard configuration of the plugin there is a section that configures it, it seems, only for Russian.
So I'm a little confused whether I'm using the plugin correctly.