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

Keymap assistance in Normal mode not working #62

Open
mario-amazing opened this issue Jan 10, 2023 · 8 comments
Open

Keymap assistance in Normal mode not working #62

mario-amazing opened this issue Jan 10, 2023 · 8 comments

Comments

@mario-amazing
Copy link

r and f commands not working with configuration from readme:

let g:XkbSwitchAssistNKeymap = 1    " for commands r and f
let g:XkbSwitchAssistSKeymap = 1    " for search lines

XkbSwitchAssistNKeymap -> not working
XkbSwitchAssistSKeymap -> working, but have deprecation messages when vim started

tried with:

set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0

and

let g:XkbSwitchDynamicKeymap = 1
@lyokha
Copy link
Owner

lyokha commented Jan 10, 2023

How do you expect it to work? Keymap assistance won't switch system keyboard layout. Instead, it relies on builtin Vim's iminsert and imsearch attributes. So, when you returned from Insert mode with, say, Russian keyboard layout, typing fg will actually find letter п. I use dynamic keymap assistance with the following config:

let g:XkbSwitchAssistNKeymap = 1    " for commands r and f
let g:XkbSwitchDynamicKeymap = 1
let g:XkbSwitchKeymapNames =
            \ {'ru' : 'russian-jcukenwin', 'de' : 'german-qwertz'}
" quickly toggle keyboard layout for f and r commands in normal mode
" (<C-^> also switches keyboard layout in search mode)
let g:XkbSwitchIminsertToggleKey = '<C-^>'
let g:XkbSwitchIminsertToggleEcho = 0

It works for me. Notice that there is mapping <C-^> for switching Keymap assistance related keyboard layout in Normal mode. Note that dynamic assistance requires setting of g:XkbSwitchKeymapNames. I also checked the simple (static) config you showed, and it worked as well.

As to XkbSwitchAssistSKeymap, it is not actually working any more (and therefore is deprecated), because now search in the command line obeys the normal keyboard layout switching flow which unites the search mode with the Insert and Select modes.

@mario-amazing
Copy link
Author

IMHO expected behaiviour the same as you described above. But when I press fg(with previous Russian language), vim tried to find g letter.
I have tried your proposal with lua config, but have the same result:

-- vim-xkbswitch
vim.g.XkbSwitchLib = '/usr/local/bin/libxkbswitch.dylib'
vim.g.XkbSwitchEnabled = 1
vim.g.XkbSwitchIMappings = { 'ru' }
vim.g.XkbSwitchAssistNKeymap = 1    -- for commands r and f
vim.g.XkbSwitchDynamicKeymap = 1
vim.g.XkbSwitchKeymapNames = {['ru'] = 'russian-jcukenwin', ['uk'] = 'ukrainian-jcuken'}
vim.g.XkbSwitchIminsertToggleEcho = 0

@lyokha
Copy link
Owner

lyokha commented Jan 10, 2023

After you return from Insert mode with Russian layout to Normal mode, what command

:echo b:xkb_layout

says? Does it say ru?

@mario-amazing
Copy link
Author

E121: Undefined variable: b:xkb_layout

@lyokha
Copy link
Owner

lyokha commented Jan 10, 2023

I made a typo, I meant b:xkb_ilayout

@mario-amazing
Copy link
Author

:echo b:xkb_ilayout: 1
when English 3

@lyokha
Copy link
Owner

lyokha commented Jan 11, 2023

Values 1 and 3 are rather weird: they are keyboard layout names and therefore should normally be like us and ru. But if you really have such names, then use dynamic keymap assistance with

let g:XkbSwitchKeymapNames = {'1' : 'russian-jcukenwin'}

@mario-amazing
Copy link
Author

Still the same behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants