dotvim/lightline.vim
rnhmjoj b19e514dde
the great restauration
* Remove unused plugins and cruft
* Remove default options (in neovim)
* Simplify statuline
* Add neomake status
2020-12-04 19:22:52 +01:00

122 lines
3.6 KiB
VimL

""
"" Settings
""
let g:lightline = {
\"active": {
\ "left": [[ "mode", "paste" ],
\ ["branch", "filename", "readonly", "ctrlp"]],
\ "right": [[ "encoding", "filetype"],
\ [ "lineinfo", "warnings", "errors"]],
\ },
\"subseparator": { 'left': '→', 'right': '∘' },
\"component": {
\ "branch" : '⚑ %{SpecialBuffer()? "" : fugitive#head()}',
\ "readonly": '%{SpecialBuffer() || !&readonly? "" : "∅"}',
\ "encoding": '%{!strlen(&fenc) || winwidth(0) < 70? "" : &fenc}',
\ "filetype": '%{SpecialBuffer() || winwidth(0) < 70? "" : strlen(&filetype) ? &filetype : "no ft"}',
\ },
\'component_visible_condition': {
\ "branch" : '(!SpecialBuffer() && strlen(fugitive#head()))',
\ "readonly": '(!SpecialBuffer() && &readonly)',
\ "filetype": '(!SpecialBuffer() && winwidth(0) > 70)',
\ "encoding": '(strlen(&fenc) && winwidth(0) > 70)',
\ },
\"component_expand": {
\ "errors": "NeomakeErr",
\ "warnings": "NeomakeWarn",
\ },
\"component_type": {
\ "errors": "error",
\ "warnings": "warning",
\ },
\"component_function": {
\ "mode": "Mode",
\ "filename": "Filename",
\ "ctrlp": "CtrlPMark",
\ }
\ }
""
"" Function helpers
""
function SpecialBuffer()
return &filetype == "help" || bufname() =~ '\v(undotree|diffpanel|ControlP)'
endfunction
function! Filename()
let fname = expand('%:t')
let mod = &modified? "Δ" : &modifiable? "" : "δ"
return fname == 'ControlP'? g:lightline.ctrlp_item :
\ SpecialBuffer()? "" :
\ (strlen(fname)? fname : 'new-file').' '.mod
endfunction
function! Mode()
let fname = expand("%:t")
return fname == "ControlP"? "CTRLP" :
\ &filetype == "help"? "HELP" :
\ bufname() =~ "undotree"? "UNDO" :
\ winwidth(0) > 60 ? lightline#mode() : ""
endfunction
function! NeomakeErr()
let errs = get(neomake#statusline#LoclistCounts(), 'E', 0)
return errs? printf('%dE', errs) : ''
endfunction
function! NeomakeWarn()
let warns = get(neomake#statusline#LoclistCounts(), 'W', 0)
return warns? printf('%dW', warns) : ''
endfunction
autocmd User NeomakeCountsChanged,NeomakeMakerFinished call lightline#update()
function! CtrlPMark()
if bufname() =~ "ControlP"
call lightline#link("iR"[g:lightline.ctrlp_regex])
endif
return ""
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
""
"" 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)