From 57cf78ba77c5adc2bf86173ab47b15f87d9504ee Mon Sep 17 00:00:00 2001 From: itchyny Date: Tue, 20 Aug 2013 17:18:01 +0900 Subject: [PATCH] readonly mark is now a member of extensions --- autoload/airline.vim | 3 +-- autoload/airline/extensions.vim | 4 ++++ autoload/airline/extensions/readonly.vim | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 autoload/airline/extensions/readonly.vim diff --git a/autoload/airline.vim b/autoload/airline.vim index 2ff44dc3..f397f0e5 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -52,8 +52,7 @@ function! airline#get_statusline(winnr, active) call builder.add_section('airline_a', s:get_section(a:winnr, 'a') \ .'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') call builder.add_section('airline_b', s:get_section(a:winnr, 'b')) - call builder.add_section('airline_c', '%<'.s:get_section(a:winnr, 'c') - \ .' %#airline_file#%{&ro ? g:airline_readonly_symbol : ""}') + call builder.add_section('airline_c', '%<'.s:get_section(a:winnr, 'c')) else call builder.add_section('airline_c', '%f%m') endif diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 454f68a7..07d536a9 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -167,6 +167,10 @@ function! airline#extensions#load() call airline#extensions#whitespace#init() endif + if (get(g:, 'airline#extensions#readonly#enabled', 1) && get(g:, 'airline_detect_readonly', 1)) + call airline#extensions#readonly#init() + endif + if g:airline_detect_iminsert call airline#extensions#iminsert#init() endif diff --git a/autoload/airline/extensions/readonly.vim b/autoload/airline/extensions/readonly.vim new file mode 100644 index 00000000..bd14c8c3 --- /dev/null +++ b/autoload/airline/extensions/readonly.vim @@ -0,0 +1,11 @@ +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +function! airline#extensions#readonly#get_mark() + return &ro ? g:airline_readonly_symbol : '' +endfunction + +function! airline#extensions#readonly#init() + let g:airline_section_c .= '%{airline#extensions#readonly#get_mark()}' +endfunction +