-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nvim-cmp bindings don't work when using Latin layout #8
Comments
In my config (https://github.com/Wansmer/nvim-config) It is a strange, that it is not remapped while |
In your config Thank you for your work, this plugin really saves me from a lot of pain! |
I'm facing a similar problem. in my case, no mapping related to local keymap = require("cmp.utils.keymap")
keymap.set_map = function(bufnr, mode, lhs, rhs, opts)
lhs = require("langmapper.utils").translate_keycode(lhs, "default", "ru")
opts.buffer = bufnr
vim.keymap.set(mode, lhs, rhs, opts)
end |
I've looked at the In addition to the option suggested above, you can disable I leave the issue open, because I will still figure it out. |
@danilshvalov thanks for the snippet, I did manage to make cmp mappings work modifying it a little bit, here's my version local keymap = require("cmp.utils.keymap")
local origin_set_map = keymap.set_map
local utils = require("langmapper.utils")
keymap.set_map = function(bufnr, mode, lhs, rhs, opts)
origin_set_map(bufnr, mode, lhs, rhs, opts)
origin_set_map(bufnr, mode, utils.translate_keycode(lhs, "default", "ru"), rhs, opts)
end |
As I understand it, the problem is that local utils = require("langmapper.utils")
local original_nvim_buf_get_keymap = vim.api.nvim_buf_get_keymap
vim.api.nvim_buf_get_keymap = function(bufnr, mode)
local maps = original_nvim_buf_get_keymap(bufnr, mode)
local filtered = {}
for _, map in ipairs(maps) do
if map.lhs == utils.translate_keycode(map.lhs, "default", "ru") then
table.insert(filtered, map)
end
end
return filtered
end
local original_nvim_get_keymap = vim.api.nvim_get_keymap
vim.api.nvim_get_keymap = function(mode)
local maps = original_nvim_get_keymap(mode)
local filtered = {}
for _, map in ipairs(maps) do
if map.lhs == utils.translate_keycode(map.lhs, "default", "ru") then
table.insert(filtered, map)
end
end
return filtered
end It also removes unnecessary mappings in |
|
Fixed with #12, thanks @danilshvalov For use with local langmapper = require("langmapper")
langmapper.setup()
langmapper.hack_get_keymap() |
nvim-cmp bindings like
<C-e>
(abort completion) and<C-f>
(scroll down through documentation) work perfectly fine in Russian layout but not in English.<C-*>
bindings set vianvim_set_keymap()
work as usual.Tested in https://github.com/Wansmer/nvim-config with only changes being
xkb-switcher
forget_current_layout_id
andru
forid
of Russian layout.The text was updated successfully, but these errors were encountered: