mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-27 07:54:44 +02:00
[add] short_path formatter in section_c
[update] test
This commit is contained in:
parent
7fc51f6952
commit
b322ee6728
8
autoload/airline/formatter/short_path.vim
Normal file
8
autoload/airline/formatter/short_path.vim
Normal 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
|
@ -146,7 +146,7 @@ function! airline#init#bootstrap()
|
|||||||
\ 'function': 'airline#parts#readonly',
|
\ 'function': 'airline#parts#readonly',
|
||||||
\ 'accent': 'red',
|
\ '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_raw('path', '%F%m')
|
||||||
call airline#parts#define('linenr', {
|
call airline#parts#define('linenr', {
|
||||||
\ 'raw': '%{g:airline_symbols.linenr}%l',
|
\ 'raw': '%{g:airline_symbols.linenr}%l',
|
||||||
|
@ -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__#'
|
Expect g:airline_section_c == '%<%f%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%#__restore__#'
|
||||||
end
|
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'
|
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)}'
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user