diff --git a/plugin/airline.vim b/plugin/airline.vim index 8c617cd..4965f67 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -23,6 +23,15 @@ let s:airline_colors_normal = g:airline#themes#{g:airline_theme}#normal let s:airline_colors_insert = g:airline#themes#{g:airline_theme}#insert let s:airline_colors_visual = g:airline#themes#{g:airline_theme}#visual +let s:airline_mode_map = { + \ 'n' : ' NORMAL ', + \ 'i' : ' INSERT ', + \ 'R' : ' RPLACE ', + \ 'v' : ' VISUAL ', + \ 'V' : ' V-LINE ', + \ 'c' : ' CMD ', + \ '' : ' V-BLCK ', + \ } let s:airline_highlight_map = { \ 'mode' : 'User2', \ 'mode_seperator' : 'User3', @@ -47,54 +56,6 @@ function! s:highlight(mode, key) exec cmd endfunction -function! AirlineModePrefix() - let l:mode = mode() - - call highlight('normal', 'statusline') - call highlight('normal', 'statusline_nc') - call highlight('normal', 'inactive') - call highlight('normal', 'mode') - call highlight('normal', 'mode_seperator') - call highlight('normal', 'info') - call highlight('normal', 'info_seperator') - call highlight('normal', 'file') - - if l:mode ==# "i" || l:mode ==# "R" - call highlight('insert', 'statusline') - call highlight('insert', 'mode') - call highlight('insert', 'mode_seperator') - call highlight('insert', 'info') - call highlight('insert', 'info_seperator') - elseif l:mode ==? "v" || l:mode ==# "" - call highlight('visual', 'statusline') - call highlight('visual', 'mode') - call highlight('visual', 'mode_seperator') - call highlight('visual', 'info') - call highlight('visual', 'info_seperator') - endif - - if l:mode ==# "n" - return " NORMAL " - elseif l:mode ==# "i" - return " INSERT " - elseif l:mode ==# "R" - return " RPLACE " - elseif l:mode ==# "v" - return " VISUAL " - elseif l:mode ==# "V" - return " V·LINE " - elseif l:mode ==# "c" - return " CMD " - elseif l:mode ==# "" - return " V·BLCK " - else - return l:mode - endif -endfunction - -" init colors on startup -call AirlineModePrefix() - function! s:update_statusline(active) let l:mode_color = a:active ? "%2*" : "%9*" let l:mode_sep_color = a:active ? "%3*" : "%9*" @@ -124,6 +85,41 @@ function! s:update_statusline(active) call setwinvar(winnr(), '&statusline', sl) endfunction +function! AirlineModePrefix() + let l:mode = mode() + + call highlight('normal', 'statusline') + call highlight('normal', 'statusline_nc') + call highlight('normal', 'inactive') + call highlight('normal', 'mode') + call highlight('normal', 'mode_seperator') + call highlight('normal', 'info') + call highlight('normal', 'info_seperator') + call highlight('normal', 'file') + + if l:mode ==# "i" || l:mode ==# "R" + call highlight('insert', 'statusline') + call highlight('insert', 'mode') + call highlight('insert', 'mode_seperator') + call highlight('insert', 'info') + call highlight('insert', 'info_seperator') + elseif l:mode ==? "v" || l:mode ==# "" + call highlight('visual', 'statusline') + call highlight('visual', 'mode') + call highlight('visual', 'mode_seperator') + call highlight('visual', 'info') + call highlight('visual', 'info_seperator') + endif + + if has_key(s:airline_mode_map, l:mode) + return s:airline_mode_map[l:mode] + endif + return l:mode +endfunction + +" init colors on startup +call AirlineModePrefix() + augroup airline au! autocmd WinLeave * call update_statusline(0)