diff --git a/autoload/airline/extensions/tabline.vim b/autoload/airline/extensions/tabline.vim index d502276a..4ce654c2 100644 --- a/autoload/airline/extensions/tabline.vim +++ b/autoload/airline/extensions/tabline.vim @@ -3,6 +3,9 @@ let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':p:.') let s:excludes = get(g:, 'airline#extensions#tabline#excludes', []) +let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0) +let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s: ') +let s:buf_modified_symbol = g:airline_symbols.modified function! airline#extensions#tabline#init(ext) if has('gui_running') @@ -37,11 +40,24 @@ function! airline#extensions#tabline#title(n) endfunction function! airline#extensions#tabline#get_buffer_name(nr) + let _ = '' let name = bufname(a:nr) - if empty(name) - return '[No Name]' + + if s:buf_nr_show + let _ .= printf(s:buf_nr_format, a:nr) endif - return fnamemodify(name, s:fmod) + + if empty(name) + let _ .= '[No Name]' + else + let _ .= fnamemodify(name, s:fmod) + endif + + if getbufvar(a:nr, '&modified') == 1 + let _ .= s:buf_modified_symbol + endif + + return _ endfunction function! s:get_buffers() diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index 972a4fa4..46073abe 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -54,6 +54,7 @@ function! airline#init#bootstrap() \ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? '✹' : '!', \ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ), \ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''), + \ 'modified': '+', \ }, 'keep') call airline#parts#define_function('mode', 'airline#parts#mode') diff --git a/doc/airline.txt b/doc/airline.txt index 9436e274..f15b29ba 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -302,6 +302,12 @@ virtualenv * configure filename match rules to exclude from the tabline. > let g:airline#extensions#tabline#excludes = [] < +* configure whether buffer numbers should be shown. > + let g:airline#extensions#tabline#buffer_nr_show = 0 +< +* configure how buffer numbers should be formatted with |printf|. > + let g:airline#extensions#tabline#buffer_nr_format = '%s: ' +< Note: Enabling this extension will modify |showtabline| and |guioptions|. ==============================================================================