Skip to content
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

Can't have keybindings in a non-latin language #2131

Open
2 tasks done
RobberFox opened this issue Jan 26, 2025 · 2 comments
Open
2 tasks done

Can't have keybindings in a non-latin language #2131

RobberFox opened this issue Jan 26, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@RobberFox
Copy link

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
	local lazyrepo = "https://github.com/folke/lazy.nvim.git"
	local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
	if vim.v.shell_error ~= 0 then
		vim.api.nvim_echo({
			{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
			{ out, "WarningMsg" },
			{ "\nPress any key to exit..." },
		}, true, {})
		vim.fn.getchar()
		os.exit(1)
	end
end

vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
	spec = {
		{
			'hrsh7th/nvim-cmp',
			event = 'InsertEnter',
			dependencies = {
				'saadparwaiz1/cmp_luasnip',
				'hrsh7th/cmp-nvim-lsp',
				'hrsh7th/cmp-path',
			},

			config = function()
				local cmp = require("cmp")
				local luasnip = require("luasnip")

				cmp.setup {
					snippet = {
						expand = function(args)
							luasnip.lsp_expand(args.body)
						end,
					},
					completion = { completeopt = "menu,menuone,noinsert" },

					-- See `:help ins-completion`
					mapping = {
						["<C-y>"] = cmp.mapping.confirm { select = true },
						["<C-н>"] = cmp.mapping.confirm { select = true },
					},
					sources = {
						{ name = "luasnip" },
					},
				}
			end,
		},

		{
			"L3MON4D3/LuaSnip",
			version = "v2.*",
			build = "make install_jsregexp",

			config = function()
				local ls = require("luasnip")
				local s = ls.snippet
				local t = ls.text_node

				ls.add_snippets("all", {
					s({ trig="random" }, t"random snippet example"),
				})
			end
		},
	},
})

Description

For example, I can't assign <C-н> to confirm the suggestion, i.e. instead of y I have a non-latin character like н

Steps to reproduce

type req and try to confirm the suggestion using a keybind in a different (non-latin) keyboard language

Expected behavior

Being able to use such hotkey

Actual behavior

Can't use such hotkey

Additional context

No response

@RobberFox RobberFox added the bug Something isn't working label Jan 26, 2025
@RobberFox
Copy link
Author

RobberFox commented Jan 26, 2025

Here is a similar-ish bug report: #2113

P.S. Just noticed that this is probably a duplicate of #2129

@RobberFox
Copy link
Author

In cmp/utils/keymap.lua I can add extend the lua pattern to account for the cyrillic alphabet \u{0400}-\u{04ff}, lines 11 and 20:

keymap.t = function(keys)
  return (string.gsub(keys, "(<[A-Za-z\u{0400}-\u{04ff}0-9\\%-%[%]%^@;,:_'`%./]->)", function(match)
...

keymap.normalize = vim.fn.has('nvim-0.8') == 1 and function(keys)
    local t = string.gsub(keys, "<([A-Za-z\u{0400}-\u{04ff}0-9\\%-%[%]%^@;,:_'`%./]-)>", function(match)
...

But that's, obviously, not sustainable at a large scale, since you can't account for every alphabet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant