Skip to content

Instantly share code, notes, and snippets.

@ayang
Last active December 12, 2017 13:45
Show Gist options
  • Save ayang/656b0fa1f4eeef254a51 to your computer and use it in GitHub Desktop.
Save ayang/656b0fa1f4eeef254a51 to your computer and use it in GitHub Desktop.
Auto change fcitx input method status for vim different mode
let w:insert_input_active = 0
function FcitxLeaveInsert()
let s:input_status = system("fcitx-remote")
if s:input_status == 2
let w:insert_input_active = 1
let l:a = system("fcitx-remote -c")
endif
endfunction
function FcitxEnterInsert()
if !exists(w:insert_input_active)
let w:insert_input_active = 0
endif
if w:insert_input_active != 0
let l:a = system("fcitx-remote -o")
let w:insert_input_active = 0
endif
endfunction
autocmd InsertLeave * call FcitxLeaveInsert()
autocmd InsertEnter * call FcitxEnterInsert()
set timeoutlen=15
@jinhwanlazy
Copy link

It works fine mostly but behaves bad when I have multiple panes opened. It yields following error when entering insert mode and hooks my cursor onto it.

Error detected while processing function FcitxEnterInsert:
line    1:
E121: Undefined variable: w:insert_input_active
Press ENTER or type command to continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment