hardtime.nvim icon indicating copy to clipboard operation
hardtime.nvim copied to clipboard

any keys remapped by a langmap are not restricted

Open han-solo318 opened this issue 1 year ago • 0 comments

Describe the bug any keys remapped by a langmap are not restricted when added to restricted keys.

Config options The options table passed into the setup() function.

opts = {
	restriction_mode = "block",
	restricted_keys = {
		['n'] = { 'n', 'x' },
		['e'] = { 'n', 'x' },
		['i'] = { 'n', 'x' },
},

or, alternatively

opts = {
	restriction_mode = "block",
	restricted_keys = {
		['j'] = { 'n', 'x' },
		['k'] = { 'n', 'x' },
		['l'] = { 'n', 'x' },
},

To Reproduce Steps to reproduce the behavior:

  1. Set a langmap, like the one below that I use, which runs before plugins are loaded:
vim.opt.langmap = vim.fn.join({
	'nN' .. ';' .. 'jJ',
	'eE' .. ';' .. 'kK',
	'iI' .. ';' .. 'lL',
	'kK' .. ';' .. 'nN',
	'uU' .. ';' .. 'iI',
	'lL' .. ';' .. 'uU',
	'fF' .. ';' .. 'eE',
	'tT' .. ';' .. 'fF',
	'jJ' .. ';' .. 'tT',
}, ',')
  1. Load plugins (in this case with lazy.nvim).
  2. press restricted key repeatedly

Expected behavior should get notification saying "You pressed too soon!" either by default or if manually set in cfg

Screenshots N/A

Additional context I saw people ran into similar issues when remapping the movement keys, but I can't move my langmap into keys the way a single binding can be moved. For keys/sequences which were affected using hint, I had to manually change the hotkeys, but after doing so, they worked. However, since the restriction of the movement keys are taken care of in the init.lua function rather than the config, I couldn't find any way to customize/change this:

https://github.com/m4xshen/hardtime.nvim/blob/6513bf42cd9261669d1ee41ff8b4065dfdc53a09/lua/hardtime/init.lua#L98-L107

han-solo318 avatar Oct 01 '24 15:10 han-solo318