implement showing buffer numbers and modified (#212).

This commit is contained in:
Bailey Ling 2013-09-04 15:47:05 +00:00
parent c144543d03
commit e167e67819
3 changed files with 26 additions and 3 deletions

View File

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

View File

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

View File

@ -302,6 +302,12 @@ virtualenv <https://github.com/jmcantrell/vim-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|.
==============================================================================