[add#keymap] more customization

Added more customization for keymap extension
This commit is contained in:
Nick Friday 2020-11-04 20:46:00 +03:00
parent 44b7b72938
commit 193460137a
2 changed files with 21 additions and 1 deletions

View File

@ -9,7 +9,18 @@ endif
function! airline#extensions#keymap#status()
if (get(g:, 'airline#extensions#keymap#enabled', 1) && has('keymap'))
return printf('%s', (!empty(&keymap) && &iminsert ? (g:airline_symbols.keymap . ' '. &keymap) : ''))
let short_codes = get(g:, 'airline#extensions#keymap#short_codes')
let label = get(g:, 'airline#extensions#keymap#label', g:airline_symbols.keymap)
let default = get(g:, 'airline#extensions#keymap#default', '')
if (label !=# '')
let label .= ' '
endif
let keymap = &keymap
if has_key(short_codes, keymap)
let keymap = short_codes[keymap]
endif
return printf('%s', (!empty(keymap) && &iminsert ? (label . keymap) :
\ (!empty(default) ? label . default : default)))
else
return ''
endif

View File

@ -826,6 +826,15 @@ This extension displays the current 'keymap' in use.
* enable/disable vim-keymap extension >
let g:airline#extensions#keymap#enabled = 1
* set label for a keymap (default is from g:airline_symbols.keymap) >
let g:airline#extensions#keymap#label = 'Layout:'
* set name for default lauout (empty to disable it completely) >
let g:airline#extensions#keymap#default = ''
* set short codes for layout names >
let g:airline#extensions#keymap#short_codes = {'russian-jcukenwin': 'ru'}
------------------------------------- *airline-languageclient*
LanguageClient <https://github.com/autozimu/LanguageClient-neovim>
(despite its name, it can be used for Vim and Neovim).