dotvim/lightline.vim
2015-10-11 02:45:58 +02:00

136 lines
3.8 KiB
VimL

""
"" Settings
""
let g:lightline = {
\"active": {
\ "left": [[ "mode", "paste" ],
\ ["fugitive", "filename", "readonly", "ctrlpmark"]],
\ "right": [ ["syntastic", "percent"],
\ ["fileencoding", "filetype"]]
\ },
\'separator': { 'left': '', 'right': '' },
\'subseparator': { 'left': '→', 'right': '∘' },
\"component": {
\"readonly": '%{&filetype=="help"?"":&readonly?"∅":""}',
\"modified": '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\'component_visible_condition': {
\"readonly": '(&filetype!="help"&& &readonly)',
\"modified": '(&filetype!="help"&&(&modified||!&modifiable))'
\ },
\"component_expand": {
\ "syntastic": "SyntasticStatuslineFlag",
\ },
\"component_type": {
\ "syntastic": "error",
\ },
\"component_function": {
\ "filename": "Filename",
\ "fugitive": "Fugitive",
\ "filetype": "Filetype",
\ "fileencoding": "Fileencoding",
\ "mode": "Mode",
\ "ctrlpmark": "CtrlPMark",
\ }
\ }
""
"" Color scheme
""
let s:p = {'normal': {}, 'inactive': {},
\'insert': {}, 'replace' : {},
\'visual': {}, 'tabline' : {}}
let s:p.normal.left = [ [ 07, 14 ], [ 08, 00 ] ]
let s:p.insert.left = [ [ 07, 05 ], [ 14, 00 ] ]
let s:p.visual.left = [ [ 00, 03 ], [ 14, 00 ] ]
let s:p.replace.left = [ [ 00, 02 ], [ 14, 00 ] ]
let s:p.inactive.left = [ [ 12, 00 ], [ 15, 00 ] ]
let s:p.tabline.left = [ [ 14, 00 ] ]
let s:p.normal.right = [ [ 12, 00 ], [ 03, 00 ] ]
let s:p.tabline.right = [ [ 12, 00 ], [ 03, 00 ] ]
let s:p.inactive.right = [ [ 12, 00 ], [ 13, 00 ] ]
let s:p.normal.middle = [ [ 12, 00 ] ]
let s:p.inactive.middle = [ [ 12, 00 ] ]
let s:p.tabline.middle = [ [ 14, 00 ] ]
let s:p.tabline.tabsel = [ [ 14, 00 ] ]
let s:p.normal.error = [ [ 00, 05 ] ]
let s:p.normal.warning = [ [ 00, 02 ] ]
let g:lightline#colorscheme#default#palette = lightline#colorscheme#fill(s:p)
""
"" Function helpers
""
function! Fugitive()
if &ft !~? 'tagbar' && exists("*fugitive#head")
let _ = fugitive#head()
return strlen(_) ? "Σ "._ : ""
endif
return ''
endfunction
function! Modified()
return &ft =~ "help" ? "" : &modified ? "Δ" : &modifiable ? "" : "δ"
endfunction
function! Readonly()
return &ft !~? "help" && &readonly ? "RO" : ""
endfunction
function! Filename()
let fname = expand('%:t')
return fname == 'ControlP' ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
\ ('' != fname ? fname : '[No Name]') .
\ ('' != Modified() ? ' ' . Modified() : '')
endfunction
function! Filetype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : "no ft") : ""
endfunction
function! Fileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : ""
endfunction
function! Mode()
let fname = expand("%:t")
return fname == "__Tagbar__" ? "Tagbar" :
\ fname == "ControlP" ? "CtrlP" :
\ winwidth(0) > 60 ? lightline#mode() : ""
endfunction
function! CtrlPMark()
if expand("%:t") =~ "ControlP"
call lightline#link("iR"[g:lightline.ctrlp_regex])
return lightline#concatenate([g:lightline.ctrlp_prev,
\ g:lightline.ctrlp_item,
\ g:lightline.ctrlp_next], 0)
else
return ""
endif
endfunction
function! CtrlPStatusMain(focus, byfname, regex, prev, item, next, marked)
let g:lightline.ctrlp_regex = a:regex
let g:lightline.ctrlp_prev = a:prev
let g:lightline.ctrlp_item = a:item
let g:lightline.ctrlp_next = a:next
return lightline#statusline(0)
endfunction
function! CtrlPStatusProg(str)
return lightline#statusline(0)
endfunction
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction