2013-08-30 23:56:12 +02:00
|
|
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2013-08-31 23:42:09 +02:00
|
|
|
call airline#init#bootstrap()
|
2013-09-19 04:23:50 +02:00
|
|
|
let s:spc = g:airline_symbols.space
|
2013-08-31 23:42:09 +02:00
|
|
|
|
2013-09-23 17:45:44 +02:00
|
|
|
function! s:wrap_accent(part, value)
|
|
|
|
if exists('a:part.accent')
|
2013-11-01 05:54:10 +01:00
|
|
|
call airline#highlighter#add_accent(a:part.accent)
|
2013-09-23 17:45:44 +02:00
|
|
|
return '%#__accent_'.(a:part.accent).'#'.a:value.'%#__restore__#'
|
|
|
|
endif
|
|
|
|
return a:value
|
|
|
|
endfunction
|
|
|
|
|
2013-09-01 18:07:46 +02:00
|
|
|
function! s:create(parts, append)
|
|
|
|
let _ = ''
|
|
|
|
for idx in range(len(a:parts))
|
|
|
|
let part = airline#parts#get(a:parts[idx])
|
|
|
|
let val = ''
|
|
|
|
|
|
|
|
if exists('part.function')
|
|
|
|
let func = (part.function).'()'
|
|
|
|
elseif exists('part.text')
|
|
|
|
let func = '"'.(part.text).'"'
|
|
|
|
else
|
|
|
|
if a:append > 0 && idx != 0
|
2013-09-19 04:23:50 +02:00
|
|
|
let val .= s:spc.g:airline_left_alt_sep.s:spc
|
2013-09-01 18:07:46 +02:00
|
|
|
endif
|
|
|
|
if a:append < 0 && idx != 0
|
2013-09-19 04:23:50 +02:00
|
|
|
let val = s:spc.g:airline_right_alt_sep.s:spc.val
|
2013-09-01 18:07:46 +02:00
|
|
|
endif
|
|
|
|
if exists('part.raw')
|
2013-09-23 17:45:44 +02:00
|
|
|
let _ .= s:wrap_accent(part, val.(part.raw))
|
2013-09-01 18:07:46 +02:00
|
|
|
continue
|
|
|
|
else
|
2013-09-23 17:45:44 +02:00
|
|
|
let _ .= s:wrap_accent(part, val.a:parts[idx])
|
2013-09-01 18:07:46 +02:00
|
|
|
continue
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
let minwidth = get(part, 'minwidth', 0)
|
|
|
|
|
|
|
|
if a:append > 0 && idx != 0
|
2013-09-09 01:06:57 +02:00
|
|
|
let partval = printf('%%{airline#util#append(%s,%s)}', func, minwidth)
|
2013-09-01 18:07:46 +02:00
|
|
|
elseif a:append < 0 && idx != len(a:parts) - 1
|
2013-09-09 01:06:57 +02:00
|
|
|
let partval = printf('%%{airline#util#prepend(%s,%s)}', func, minwidth)
|
2013-09-01 18:07:46 +02:00
|
|
|
else
|
2013-09-09 01:06:57 +02:00
|
|
|
let partval = printf('%%{airline#util#wrap(%s,%s)}', func, minwidth)
|
2013-09-01 18:07:46 +02:00
|
|
|
endif
|
2013-09-09 01:06:57 +02:00
|
|
|
|
|
|
|
if exists('part.condition')
|
|
|
|
let partval = substitute(partval, '{', '{'.(part.condition).' ? ', '')
|
|
|
|
let partval = substitute(partval, '}', ' : ""}', '')
|
|
|
|
endif
|
|
|
|
|
2013-09-23 17:45:44 +02:00
|
|
|
let val .= s:wrap_accent(part, partval)
|
2013-09-01 18:07:46 +02:00
|
|
|
let _ .= val
|
|
|
|
endfor
|
|
|
|
return _
|
2013-08-30 23:56:12 +02:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create(parts)
|
2013-09-01 18:07:46 +02:00
|
|
|
return s:create(a:parts, 0)
|
2013-08-30 23:56:12 +02:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create_left(parts)
|
2013-09-01 18:07:46 +02:00
|
|
|
return s:create(a:parts, 1)
|
2013-08-30 23:56:12 +02:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create_right(parts)
|
2013-09-01 18:07:46 +02:00
|
|
|
return s:create(a:parts, -1)
|
2013-08-30 23:56:12 +02:00
|
|
|
endfunction
|
|
|
|
|