From 3877ddb7bb31ee7c7d8403e9ed5f4bc07812ef22 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Mon, 1 Jul 2013 23:45:49 -0400 Subject: [PATCH] implement support for detected modified buffers --- autoload/airline/themes/default.vim | 9 +++++++++ doc/airline.txt | 5 +++++ plugin/airline.vim | 18 +++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/autoload/airline/themes/default.vim b/autoload/airline/themes/default.vim index bb24d5ad..aaf4c411 100644 --- a/autoload/airline/themes/default.vim +++ b/autoload/airline/themes/default.vim @@ -8,6 +8,9 @@ let g:airline#themes#default#normal = { \ 'file': [ '#ff0000' , '#1c1c1c' , 160 , 233 , '' ] , \ 'inactive': [ '#4e4e4e' , '#1c1c1c' , 239 , 234 , '' ] , \ } +let g:airline#themes#default#normal_modified = copy(g:airline#themes#default#normal) +let g:airline#themes#default#normal_modified.info_seperator = [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] +let g:airline#themes#default#normal_modified.statusline = [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] let g:airline#themes#default#insert = { \ 'mode': [ '#00005f' , '#00dfff' , 17 , 45 , 'bold' ] , @@ -16,6 +19,9 @@ let g:airline#themes#default#insert = { \ 'info_seperator': [ '#005fff' , '#000087' , 27 , 18 , 'bold' ] , \ 'statusline': [ '#ffffff' , '#000080' , 15 , 17 , '' ] , \ } +let g:airline#themes#default#insert_modified = copy(g:airline#themes#default#insert) +let g:airline#themes#default#insert_modified.info_seperator = [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] +let g:airline#themes#default#insert_modified.statusline = [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] let g:airline#themes#default#visual = { \ 'mode': [ '#000000' , '#ffaf00' , 232 , 214 , 'bold' ] , @@ -24,3 +30,6 @@ let g:airline#themes#default#visual = { \ 'info_seperator': [ '#ff5f00' , '#5f0000' , 202 , 52 , 'bold' ] , \ 'statusline': [ '#ffffff' , '#5f0000' , 15 , 52 , '' ] , \ } +let g:airline#themes#default#visual_modified = copy(g:airline#themes#default#visual) +let g:airline#themes#default#visual_modified.info_seperator = [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] +let g:airline#themes#default#visual_modified.statusline = [ '#ffffff' , '#5f005f' , 255 , 53 , '' ] diff --git a/doc/airline.txt b/doc/airline.txt index 2ca6dd4e..70c5fcc0 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -40,6 +40,11 @@ values): let g:airline_left_right='<' < +* enable/disable color change when buffer is modified +> + let g:airline_modified_detection=1 +< + * enable/disable fugitive integration > let g:airline_enable_fugitive=1 diff --git a/plugin/airline.vim b/plugin/airline.vim index 116bdb76..8a3af6a0 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -22,12 +22,16 @@ endif if !exists('g:airline_theme') let g:airline_theme = 'default' endif +if !exists('g:airline_modified_detection') + let g:airline_modified_detection=1 +endif set laststatus=2 -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 +for mode in ['normal','insert','visual'] + let s:airline_colors_{mode} = g:airline#themes#{g:airline_theme}#{mode} + let s:airline_colors_{mode}_modified = g:airline#themes#{g:airline_theme}#{mode}_modified +endfor let s:airline_mode_map = { \ 'n' : ' NORMAL ', @@ -50,9 +54,13 @@ let s:airline_highlight_map = { \ } function! s:highlight(mode, keys) + let l:mode = a:mode + if g:airline_modified_detection && &modified + let l:mode .= '_modified' + endif for key in a:keys - if exists('s:airline_colors_{a:mode}') && exists('s:airline_colors_{a:mode}[key]') - let colors = s:airline_colors_{a:mode}[key] + if exists('s:airline_colors_{l:mode}') && exists('s:airline_colors_{l:mode}[key]') + let colors = s:airline_colors_{l:mode}[key] let cmd = printf('hi %s %s %s %s %s %s %s', \ s:airline_highlight_map[key], \ colors[0] != '' ? 'guifg='.colors[0] : '',