[add] short_path formatter in section_c

[update] test
This commit is contained in:
kazukazuinaina 2020-07-22 17:11:22 +09:00
parent 7fc51f6952
commit b322ee6728
3 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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',

View File

@ -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