2013-08-30 17:56:12 -04:00
|
|
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2013-08-31 17:42:09 -04:00
|
|
|
call airline#init#bootstrap()
|
|
|
|
|
2013-08-30 17:56:12 -04:00
|
|
|
function! s:get_val(key, append)
|
|
|
|
let part = airline#parts#get(a:key)
|
2013-08-30 23:26:59 -04:00
|
|
|
|
|
|
|
let val = ''
|
|
|
|
if exists('part.highlight')
|
|
|
|
let val .= '%#'.(part.highlight).'#'
|
|
|
|
endif
|
|
|
|
|
2013-08-30 17:56:12 -04:00
|
|
|
if exists('part.function')
|
|
|
|
let func = (part.function).'()'
|
|
|
|
elseif exists('part.text')
|
|
|
|
let func = '"'.(part.text).'"'
|
|
|
|
elseif exists('part.raw')
|
2013-08-30 23:26:59 -04:00
|
|
|
return val.(part.raw)
|
2013-08-30 17:56:12 -04:00
|
|
|
else
|
|
|
|
return a:key
|
|
|
|
endif
|
|
|
|
|
2013-08-31 12:33:58 -04:00
|
|
|
let minwidth = get(part, 'minwidth', 0)
|
|
|
|
|
2013-08-30 17:56:12 -04:00
|
|
|
if a:append > 0
|
2013-08-31 12:33:58 -04:00
|
|
|
let val .= printf('%%{airline#util#append(%s,%s)}', func, minwidth)
|
2013-08-30 17:56:12 -04:00
|
|
|
elseif a:append < 0
|
2013-08-31 12:33:58 -04:00
|
|
|
let val .= printf('%%{airline#util#prepend(%s,%s)}', func, minwidth)
|
2013-08-30 17:56:12 -04:00
|
|
|
else
|
2013-08-31 12:33:58 -04:00
|
|
|
let val .= printf('%%{airline#util#wrap(%s,%s)}', func, minwidth)
|
2013-08-30 17:56:12 -04:00
|
|
|
endif
|
|
|
|
return val
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create(parts)
|
|
|
|
return join(map(a:parts, 's:get_val(v:val, 0)'), '')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create_left(parts)
|
|
|
|
let _ = s:get_val(a:parts[0], 0)
|
|
|
|
for i in range(1, len(a:parts) - 1)
|
|
|
|
let _ .= s:get_val(a:parts[i], 1)
|
|
|
|
endfor
|
|
|
|
return _
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create_right(parts)
|
|
|
|
let _ = ''
|
|
|
|
for i in range(0, len(a:parts) - 2)
|
|
|
|
let _ .= s:get_val(a:parts[i], -1)
|
|
|
|
endfor
|
|
|
|
let _ .= s:get_val(a:parts[-1], 0)
|
|
|
|
return _
|
|
|
|
endfunction
|
|
|
|
|