From b322ee6728ea418d99028bc2606c12dbc3b95530 Mon Sep 17 00:00:00 2001 From: kazukazuinaina Date: Wed, 22 Jul 2020 17:11:22 +0900 Subject: [PATCH 1/2] [add] short_path formatter in section_c [update] test --- autoload/airline/formatter/short_path.vim | 8 ++++++++ autoload/airline/init.vim | 2 +- t/init.vim | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 autoload/airline/formatter/short_path.vim diff --git a/autoload/airline/formatter/short_path.vim b/autoload/airline/formatter/short_path.vim new file mode 100644 index 00000000..675704e2 --- /dev/null +++ b/autoload/airline/formatter/short_path.vim @@ -0,0 +1,8 @@ +scriptencoding utf-8 + +function! airline#formatter#short_path#format(val) abort + if get(g:, 'airline_stl_path_style', 'default') ==# 'short' + return '%{pathshorten(expand("'.a:val.'"))}%' + endif + return a:val +endfunction diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index b3191d8d..f23562b0 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -146,7 +146,7 @@ function! airline#init#bootstrap() \ 'function': 'airline#parts#readonly', \ 'accent': 'red', \ }) - call airline#parts#define_raw('file', '%f%m') + call airline#parts#define_raw('file', airline#formatter#short_path#format('%f%m')) call airline#parts#define_raw('path', '%F%m') call airline#parts#define('linenr', { \ 'raw': '%{g:airline_symbols.linenr}%l', diff --git a/t/init.vim b/t/init.vim index 6cc5620e..a6a4a4f1 100644 --- a/t/init.vim +++ b/t/init.vim @@ -33,6 +33,11 @@ describe 'init sections' Expect g:airline_section_c == '%<%f%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%#__restore__#' end + it 'section c should be file and coc_status short style' + let g:airline_stl_path_style = 'short' + Expect g:airline_section_c == '%<%{airline#formatter#short_path#format("%f%m")}% %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%#__restore__#' + end + it 'section x should be filetype' Expect g:airline_section_x == '%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}' end From 7ff5fdc34923a322ae6a916e18f9cbc303ec4dcc Mon Sep 17 00:00:00 2001 From: kazukazuinaina Date: Thu, 23 Jul 2020 16:11:19 +0900 Subject: [PATCH 2/2] fix CI --- t/init.vim | 5 ----- 1 file changed, 5 deletions(-) diff --git a/t/init.vim b/t/init.vim index a6a4a4f1..6cc5620e 100644 --- a/t/init.vim +++ b/t/init.vim @@ -33,11 +33,6 @@ describe 'init sections' Expect g:airline_section_c == '%<%f%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%#__restore__#' end - it 'section c should be file and coc_status short style' - let g:airline_stl_path_style = 'short' - Expect g:airline_section_c == '%<%{airline#formatter#short_path#format("%f%m")}% %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%#__restore__#' - end - it 'section x should be filetype' Expect g:airline_section_x == '%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}' end