-
Notifications
You must be signed in to change notification settings - Fork 23
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
Libcalls to libxkbswitch
don't work properly
#27
Comments
Looks like the plugin is unable to determine keyboard layout that was set on vim load in your case. I'll look at details tomorrow because I do not have time today. But anyway setting let g:XkbSwitchNLayout = 'us' must work. Please try this and also show all your vim settings regarding the plugin. You can try also let g:XkbSwitchLoadOnBufRead = 1 this forces to load plugin on BufRead event but may clash with other plugins like EnhancedJumps in my case. If you're using the second setting, the first one is optional, however I would recommend to use the first because forcing English layout in Normal mode always looks sound. Btw here are my settings: " ---- Automatic keyboard layout switching upon entering/leaving insert mode
" ---- using xkb-switch utility and plugin xkbswitch
" ----
let g:XkbSwitchEnabled = 1
let g:XkbSwitchIMappings = ['ru']
let g:XkbSwitchNLayout = 'us'
let g:XkbSwitchILayout = 'us'
" loading xkbswitch on BufRead when bufhidden=delete will clash xkbswitch
" function imappings_load() and plugin EnhancedJumps as soon as both will do
" redir simultaneously!
let g:XkbSwitchLoadOnBufRead = 0
let g:XkbSwitchSkipIMappings =
\ {'c' : ['.', '>', ':', '{<CR>', '/*', '/*<CR>'],
\ 'cpp' : ['.', '>', ':', '{<CR>', '/*', '/*<CR>']}
let g:XkbSwitchSkipFt = [ 'conque_term' ]
let g:XkbSwitchAssistNKeymap = 1 " for commands r and f
let g:XkbSwitchAssistSKeymap = 1 " for search lines
let g:XkbSwitchDynamicKeymap = 1
let g:XkbSwitchKeymapNames = {'ru' : 'russian-jcukenwin'} |
Thanks for the reply! Unfortunately I've tried all the suggestions, including just copying your config, but the problem still persists. My current config:
If I set
I get error |
This is really suspicious. Here vim must call the function from the library without any additional processing and if it fails then there is something wrong with the function or libcall. I built latest Can you build xkb-switch manually from here and try the new library that it would install? |
@lyokha You are right, it is indeed something wrong with Arch AUR package Though the symptoms were indeed suspicious, the Arch I'll try to figure it out and fix the AUR package for Arch, but now that's a different story :) Thanks for the help to sort this out! |
Just for your information, turns out Now it's clear that the problem originates from xkb-switch code. Thanks for the help! |
Hmm. Actually I built my old fork of xkb-switch and it worked fine at any optimization level. The upstream xkb-switch does work as you explained at any optimization level. I will try to figure out what's wrong. |
I re-checked that and found that It worked bad only when optimization was on, exactly as you told. See my comment and the patch at the |
Disclaimer
The issue is very weird and I completely understand and acknowledge its weirdness, I also assume there could be something terribly wrong with my setup, however despite my thorough trials I couldn't figure out the root cause, so decided to ask for an advice here.
Issue
vim-xkbswitch
plugin doesn't switch the layout when exiting to normal mode (from insert). For instance: I start Vim, go into insert mode, switch layout to Russian and type some text, pressEsc
to return to normal: layout doesn't change. What's weird: if I manually switch back to English and repeat the procedure: go to insert, type something, exit to normal again --- then the layout gets switched (but back to Russian, since I already was in English after manual switch, so it just inverts the layout).Sounds crazy, but basically layout switch works only on the second call.
Troubleshooting
I have tried to remove all plugins and configurations from my
.vimrc
, only leave the minimal few lines to enablevim-xkbswitch
, removedxxkb
, changed Xkb settings to simplest possible setupsetxkbmap -layout 'us,ru'
even though I usually have more complicated configuration and 3 layouts.But the issue persisted:
libcall
tolibxkbswitch
switched the layout only on the second call, so the plugin messes up and gets completely confused. At the same time console utility (xkb-switch
) works as expected and successfully switches layouts with just one call. That's the reason why I decided to open issue here instead ofxkb-switch
repo, as the issue actually happens only when I use it through Vim.I went down to just manually perform the
libcall
from Vim console like so:And again nothing happens on the first call, only when I repeat this command for the second time, the layout actually changes (same when I use this command to switch back to English).
I even tried to remove the plugin and Vundle completely, and just paste the code from your article straight into
.vimrc
, but the behavior is the same.For now I could only workaround the issue by literally duplicating all
set
calls to Xkb in the plugin --- then it works.Debug info
OS: Arch Linux (of course everything is updated to latest versions).
Please let me know if there's any other useful debug info I can provide. If only I could debug the
libcall
to Xkb in detail to see what's actually going on, but I don't know how, andstrace
onxkb-switch
itself wouldn't help, as the command line utility works fine: it's onlylibcall
from Vim that misbehaves.Thank you!
The text was updated successfully, but these errors were encountered: