xkblayout: support fcitx5-ui.nvim (#2680)
https://github.com/black-desk/fcitx5-ui.nvim
This commit is contained in:
parent
16c1638f93
commit
02894b6ef4
|
@ -440,7 +440,7 @@ function! airline#extensions#load()
|
||||||
call add(s:loaded_ext, 'grepper')
|
call add(s:loaded_ext, 'grepper')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get(g:, 'airline#extensions#xkblayout#enabled', 1) && (exists('g:XkbSwitchLib') || exists('*FcitxCurrentIM'))
|
if get(g:, 'airline#extensions#xkblayout#enabled', 1) && (exists('g:XkbSwitchLib') || exists('*FcitxCurrentIM') || has('nvim'))
|
||||||
call airline#extensions#xkblayout#init(s:ext)
|
call airline#extensions#xkblayout#init(s:ext)
|
||||||
call add(s:loaded_ext, 'xkblayout')
|
call add(s:loaded_ext, 'xkblayout')
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
if !exists('g:XkbSwitchLib') && !exists('*FcitxCurrentIM')
|
if !exists('g:XkbSwitchLib') && !exists('*FcitxCurrentIM') && !has('nvim')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -11,15 +11,21 @@ function! airline#extensions#xkblayout#status()
|
||||||
if exists('g:XkbSwitchLib')
|
if exists('g:XkbSwitchLib')
|
||||||
let keyboard_layout = libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
|
let keyboard_layout = libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
|
||||||
let keyboard_layout = get(split(keyboard_layout, '\.'), -1, '')
|
let keyboard_layout = get(split(keyboard_layout, '\.'), -1, '')
|
||||||
|
elseif exists('*FcitxCurrentIMwithRime')
|
||||||
|
let keyboard_layout = FcitxCurrentIMwithRime()
|
||||||
|
elseif exists('*FcitxCurrentIM')
|
||||||
|
let keyboard_layout = FcitxCurrentIM()
|
||||||
|
elseif has('nvim')
|
||||||
|
try
|
||||||
|
let keyboard_layout = luaeval('require"fcitx5-ui".displayCurrentIM()')
|
||||||
|
catch /.*/
|
||||||
|
let keyboard_layout = ''
|
||||||
|
endtry
|
||||||
else
|
else
|
||||||
if exists('*FcitxCurrentIMwithRime')
|
let keyboard_layout = ''
|
||||||
let keyboard_layout = FcitxCurrentIMwithRime()
|
|
||||||
else
|
|
||||||
let keyboard_layout = FcitxCurrentIM()
|
|
||||||
endif
|
|
||||||
" substitute keyboard-us to us
|
|
||||||
let keyboard_layout = substitute(keyboard_layout, 'keyboard-', '', 'g')
|
|
||||||
endif
|
endif
|
||||||
|
" substitute keyboard-us to us
|
||||||
|
let keyboard_layout = substitute(keyboard_layout, 'keyboard-', '', 'g')
|
||||||
|
|
||||||
let short_codes = get(g:, 'airline#extensions#xkblayout#short_codes', {'2SetKorean': 'KR', 'Chinese': 'CN', 'Japanese': 'JP'})
|
let short_codes = get(g:, 'airline#extensions#xkblayout#short_codes', {'2SetKorean': 'KR', 'Chinese': 'CN', 'Japanese': 'JP'})
|
||||||
if has_key(short_codes, keyboard_layout)
|
if has_key(short_codes, keyboard_layout)
|
||||||
|
|
Loading…
Reference in New Issue