Merge pull request #1372 from dalguji/master

Add vim-xkblayout extension to display keyboard layout
This commit is contained in:
Christian Brabandt 2017-01-18 08:00:52 +01:00 committed by GitHub
commit bfac656da9
5 changed files with 44 additions and 1 deletions

View File

@ -284,6 +284,11 @@ function! airline#extensions#load()
call add(loaded_ext, 'capslock')
endif
if (get(g:, 'airline#extensions#xkblayout#enabled', 1) && exists('g:XkbSwitchLib'))
call airline#extensions#xkblayout#init(s:ext)
call add(loaded_ext, 'xkblayout')
endif
if (get(g:, 'airline#extensions#windowswap#enabled', 1) && get(g:, 'loaded_windowswap', 0))
call airline#extensions#windowswap#init(s:ext)
call add(loaded_ext, 'windowswap')

View File

@ -0,0 +1,25 @@
" MIT License. Copyright (c) 2017 YoungHoon Rhiu.
" vim: et ts=2 sts=2 sw=2
scriptencoding utf-8
if !exists('g:XkbSwitchLib')
finish
endif
function! airline#extensions#xkblayout#status()
let keyboard_layout = libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
let keyboard_layout = split(keyboard_layout, '\.')[-1]
let short_codes = {'2SetKorean': 'KR', 'Chinese': 'CN', 'Japanese': 'JP'}
if has_key(short_codes, keyboard_layout)
let keyboard_layout = short_codes[keyboard_layout]
endif
return keyboard_layout
endfunction
function! airline#extensions#xkblayout#init(ext)
call airline#parts#define_function('xkblayout', 'airline#extensions#xkblayout#status')
endfunction

View File

@ -104,6 +104,7 @@ function! airline#init#bootstrap()
\ 'eclim', 'whitespace','windowswap', 'ycm_error_count', 'ycm_warning_count',
\ 'neomake_error_count', 'neomake_warning_count', 'ale_error_count', 'ale_warning_count'])
call airline#parts#define_text('capslock', '')
call airline#parts#define_text('xkblayout', '')
unlet g:airline#init#bootstrapping
endfunction
@ -117,7 +118,7 @@ endfunction
function! airline#init#sections()
let spc = g:airline_symbols.space
if !exists('g:airline_section_a')
let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'spell', 'capslock', 'iminsert'])
let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'spell', 'capslock', 'xkblayout', 'iminsert'])
endif
if !exists('g:airline_section_b')
let g:airline_section_b = airline#section#create(['hunks', 'branch'])

BIN
doc/.airline.txt.swp Normal file

Binary file not shown.

View File

@ -754,6 +754,18 @@ vim-capslock <https://github.com/tpope/vim-capslock>
* enable/disable vim-capslock integration >
let g:airline#extensions#capslock#enabled = 1
------------------------------------- *airline-xkblayout*
vim-xkblayout
* enable/disable vim-xkblayout extension >
let g:airline#extensions#xkblayout#enabled = 1
* define path to the backend switcher library
Linux (Install https://github.com/ierton/xkb-switch):
let g:XkbSwitchLib = '/usr/local/lib/libxkbswitch.so'
macOS (Install https://github.com/vovkasm/input-source-switcher):
let g:XkbSwitchLib = '/usr/local/lib/libInputSourceSwitcher.dylib'
------------------------------------- *airline-windowswap*
vim-windowswap <https://github.com/wesQ3/vim-windowswap>