Giter Site home page Giter Site logo

Comments (7)

lyokha avatar lyokha commented on May 29, 2024 1

I went down to just manually perform the libcall from Vim console like so:

:call libcall(g:XkbSwitchLib, Xkb_Switch_setXkbLayout, 'ru')

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).

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 xkb-switch on my desktop and it works as fine as before. What if there is something wrong with the Arch xkb-switch? I have looked at this and read in comments that it must depend on libxkbfile but it does not if I got it correctly.

Can you build xkb-switch manually from here and try the new library that it would install?

from vim-xkbswitch.

lyokha avatar lyokha commented on May 29, 2024 1

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 xkb-switch bug report. This must work. Surprisingly, my old fork worked fine with optimization set, yet it used the same XkbLockGroup() without accommodation.

from vim-xkbswitch.

lyokha avatar lyokha commented on May 29, 2024

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'}

from vim-xkbswitch.

rkiyanchuk avatar rkiyanchuk commented on May 29, 2024

Thanks for the reply! Unfortunately I've tried all the suggestions, including just copying your config, but the problem still persists.

My current config:

let $VIMHOME=$HOME . "/.vim"
let $VIMBUNDLE=$VIMHOME . "/bundle"

filetype off  " Filetype recognition must be disabled for Vundle setup.
set rtp+=$VIMBUNDLE/Vundle.vim/
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'  " Vim plugin manager.
Plugin 'lyokha/vim-xkbswitch'  " Automatic keyboard layout switcher.

call vundle#end()
filetype plugin indent on

let g:XkbSwitchEnabled = 1
let g:XkbSwitchIMappings = ['ru']
let g:XkbSwitchNLayout = 'us'
let g:XkbSwitchILayout = 'us'
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'}

If I set

let g:XkbSwitchLoadOnBufRead = 1

I get error No mapping found on startup, however I do have russian-jcukenwin.vim mapping in /usr/share/vim74/keymap directory :\

from vim-xkbswitch.

rkiyanchuk avatar rkiyanchuk commented on May 29, 2024

@lyokha You are right, it is indeed something wrong with Arch AUR package xkb-switch-git — once I built locally from upstream repo and replaced libxkbswitch.so, the plugin started working as expected again.

Though the symptoms were indeed suspicious, the Arch PKGFILE seems to be straightforward, yet it does something wrong that libxkbswitch starts to act so weird.

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!

from vim-xkbswitch.

rkiyanchuk avatar rkiyanchuk commented on May 29, 2024

Just for your information, turns out makepkg builds Arch packages with -O2 compile flag by default and this causes problem with xkb-switch library. I've tried to manually compile upstream xkb-switch code with -O2 and was able to reproduce the same problem using the resulting lib without building Arch package.

Now it's clear that the problem originates from xkb-switch code.

Thanks for the help!

from vim-xkbswitch.

lyokha avatar lyokha commented on May 29, 2024

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.

from vim-xkbswitch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.