make ...#fnamemod configurable during runtime
airline#extensions#tabline#fnamemod would be initialized and could not be changed during runtime, so fix that. closes #1347
This commit is contained in:
parent
ccdc3d6c60
commit
04be981de9
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
|
|
||||||
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
|
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
|
||||||
let s:fnametruncate = get(g:, 'airline#extensions#tabline#fnametruncate', 0)
|
let s:fnametruncate = get(g:, 'airline#extensions#tabline#fnametruncate', 0)
|
||||||
let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s: ')
|
let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s: ')
|
||||||
|
@ -11,6 +10,7 @@ let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0)
|
||||||
let s:buf_modified_symbol = g:airline_symbols.modified
|
let s:buf_modified_symbol = g:airline_symbols.modified
|
||||||
|
|
||||||
function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
|
function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
|
||||||
|
let fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
|
||||||
let _ = ''
|
let _ = ''
|
||||||
|
|
||||||
let name = bufname(a:bufnr)
|
let name = bufname(a:bufnr)
|
||||||
|
@ -18,9 +18,9 @@ function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
|
||||||
let _ .= '[No Name]'
|
let _ .= '[No Name]'
|
||||||
else
|
else
|
||||||
if s:fnamecollapse
|
if s:fnamecollapse
|
||||||
let _ .= substitute(fnamemodify(name, s:fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
|
let _ .= substitute(fnamemodify(name, fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
|
||||||
else
|
else
|
||||||
let _ .= fnamemodify(name, s:fmod)
|
let _ .= fnamemodify(name, fmod)
|
||||||
endif
|
endif
|
||||||
if a:bufnr != bufnr('%') && s:fnametruncate && strlen(_) > s:fnametruncate
|
if a:bufnr != bufnr('%') && s:fnametruncate && strlen(_) > s:fnametruncate
|
||||||
let _ = strpart(_, 0, s:fnametruncate)
|
let _ = strpart(_, 0, s:fnametruncate)
|
||||||
|
|
Loading…
Reference in New Issue