From 384150ecd7c76aa15391bcb6d1df49f0391218a1 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 10 Aug 2013 17:02:48 -0400 Subject: [PATCH] extract iminsert out of core into an extension --- autoload/airline.vim | 10 +--------- autoload/airline/extensions.vim | 4 ++++ autoload/airline/extensions/iminsert.vim | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 autoload/airline/extensions/iminsert.vim diff --git a/autoload/airline.vim b/autoload/airline.vim index 525bf25..c84167c 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -163,20 +163,12 @@ function! airline#update_highlight() let l:mode = ['insert'] elseif l:m ==# "R" let l:mode = ['replace'] - elseif l:m =~# '\v(v|V|)' - let l:mode = ['visual'] - elseif l:m =~# '\v(s|S|)' + elseif l:m =~# '\v(v|V||s|S|)' let l:mode = ['visual'] else let l:mode = ['normal'] endif let g:airline_current_mode_text = get(g:airline_mode_map, l:m, l:m) - if g:airline_detect_iminsert && &iminsert - if get(g:, 'airline_powerline_fonts', 0) - let g:airline_current_mode_text .= ' '.g:airline_left_alt_sep - endif - let g:airline_current_mode_text .= ' '.toupper(get(b:, 'keymap_name', 'lang')) - endif else let l:mode = ['inactive'] endif diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 8176a5b..92c283b 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -139,6 +139,10 @@ function! airline#extensions#load() call airline#extensions#whitespace#init() endif + if g:airline_detect_iminsert + call airline#extensions#iminsert#init() + endif + call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0) endfunction diff --git a/autoload/airline/extensions/iminsert.vim b/autoload/airline/extensions/iminsert.vim new file mode 100644 index 0000000..5357cad --- /dev/null +++ b/autoload/airline/extensions/iminsert.vim @@ -0,0 +1,14 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: ts=2 sts=2 sw=2 fdm=indent + +function! airline#extensions#iminsert#get_text() + if &iminsert + return toupper(get(b:, 'keymap_name', 'lang')) + endif + return '' +endfunction + +function! airline#extensions#iminsert#init() + let g:airline_section_a .= ' '.g:airline_left_alt_sep.' %{airline#extensions#iminsert#get_text()}' +endfunction +