mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 09:22:53 +08:00
implement showing buffer numbers and modified (#212).
This commit is contained in:
parent
c144543d03
commit
e167e67819
|
@ -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()
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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|.
|
||||
|
||||
==============================================================================
|
||||
|
|
Loading…
Reference in New Issue
Block a user