Merge pull request #2273 from NFrid/master

add more customization options for keymap extension
This commit is contained in:
Christian Brabandt 2020-11-05 09:23:58 +01:00 committed by GitHub
commit dcebc6d2aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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).