letg:lightline = {
\ 'colorscheme': 'tender',
\ 'active': {
\ 'left': [ [ 'mode','paste' ], [ 'fugitive','filename' ] ],
\ 'right': [ [ 'lineinfo' ], ['percent'], [ 'ale_error','ale_warning','ale_ok','char_code','fileformat','fileencoding','filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'char_code': 'LightLineCharCode',
\ },
\ 'component_function_visible_condition': {
\ 'mode': 1,
\ },
\ 'component_expand': {
\ 'ale_error': 'LightLineAleError',
\ 'ale_warning': 'LightLineAleWarning',
\ 'ale_ok': 'LightLineAleOk',
\ },
\ 'component_type': {
\ 'ale_error': 'error',
\ 'ale_waring': 'waring',
\ 'ale_ok': 'ok',
\ },
\ 'separator': {'left': '⮀','right': '⮂'},
\ 'subseparator': {'left': '⮁','right': '⮃'}
\ }
augroup LightLineOnALE
autocmd!
autocmd User ALELint call lightline#update()
augroup END
function! LightLineModified()return&ft=~'help' ? '' : &modified ? '' : &modifiable ? '' : '-'endfunctionfunction! LightLineReadonly()return&ft!~? 'help'&& &readonly ? '' : ''endfunctionfunction! LightLineFilepath() abort
letl:path_string = substitute(expand('%:h'), $HOME,'~','')ifwinwidth(0)<120&& len(l:path_string)>30letl:path_string = substitute(l:path_string,'\v([^/])[^/]*%(/)@=','\1','g')endifreturnl:path_string
endfunctionfunction! LightLineFilename()let fname = expand('%:t')return fname =='ControlP' ? g:lightline.ctrlp_item :
\ fname =='__Tagbar__' ? g:lightline.fname :
\ fname =~'__Gundo\|NERD_tree' ? '' :
\ &ft=='vimfiler' ? vimfiler#get_status_string() :
\ &ft=='denite' ? LightLineDenite() :
\ &ft=='vimshell' ? vimshell#get_status_string() :
\ (''!= LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ (''!= fname ? LightLineFilepath().' '.fname : '[No Name]') .
\ (''!= LightLineModified() ? ' ' . LightLineModified() : '')endfunction" ref. https://gist.github.com/pocari/84c78efa38b5c2fc1f659d1aac3face8function! LightLineDenite()let mode_str = substitute(denite#get_status_mode(),"-\\| ","","g")call lightline#link(tolower(mode_str[0]))return mode_str
endfunctionfunction! LightLineFugitive()tryif expand('%:t')!~? 'Tagbar\|Gundo\|NERD'&& &ft!~? 'vimfiler'&& exists('*fugitive#head')let mark =' '" edit here for cool marklet _ = fugitive#head()return strlen(_) ? mark._ : ''endifcatchendtryreturn''endfunctionfunction! LightLineFileformat()returnwinwidth(0)>120 ? &fileformat . (exists('*WebDevIconsGetFileFormatSymbol') ? ' ' . WebDevIconsGetFileFormatSymbol() : '') : ''endfunctionfunction! LightLineFiletype()returnwinwidth(0)>70 ? (strlen(&filetype) ? &filetype . (exists('*WebDevIconsGetFileTypeSymbol') ? ' ' . WebDevIconsGetFileTypeSymbol() : ''): 'no ft') : ''endfunctionfunction! LightLineFileencoding()returnwinwidth(0)>120 ? (strlen(&fenc) ? &fenc : &enc) : ''endfunctionfunction! LightLineMode()let fname = expand('%:t')return fname =='__Tagbar__' ? 'Tagbar' :
\ fname =='ControlP' ? 'CtrlP' :
\ fname =='__Gundo__' ? 'Gundo' :
\ fname =='__Gundo_Preview__' ? 'Gundo Preview' :
\ fname =~'NERD_tree' ? 'NERDTree' :
\ &ft=='unite' ? 'Unite' :
\ &ft=='denite' ? 'Denite' :
\ &ft=='vimfiler' ? 'VimFiler' :
\ &ft=='vimshell' ? 'VimShell' :
\ winwidth(0)>60 ? lightline#mode() : ''endfunctionfunction! LightLineCharCode() abort
ifwinwidth(0)<=120return''endif " if char on cursor is `Λ̊`, :ascii returns below. " <Λ> 923, 16進数 039b, 8進数 1633 < ̊> 778, 16進数 030a, 8進数 1412redir=>l:tmp |silent!ascii|redir END
letl:chars = []
call substitute(l:tmp,'<.>\s\+\d\+,\s\+\S\+ \x\+,\s\+\S\+ \d\+','\=add(l:chars, submatch(0))','g')if len(l:chars)==0return''endifletl:ascii= []
forl:cinl:chars
letl:m= matchlist(l:c,'<\(.\)>\s\+\d\+,\s\+\S\+ \(\x\+\)')if len(l:m)>0call add(l:ascii, printf('%s %s',l:m[1],l:m[2]))endifendforreturnjoin(l:ascii,', ')endfunctionfunction! LightLineAleError() abort
return s:ale_string(0)endfunctionfunction! LightLineAleWarning() abort
return s:ale_string(1)endfunctionfunction! LightLineAleOk() abort
return s:ale_string(2)endfunctionfunction! s:ale_string(mode)if!exists('g:ale_buffer_info')return''endifletl:buffer = bufnr('%')letl:counts = ale#statusline#Count(l:buffer)let [l:error_format,l:warning_format,l:no_errors] =g:ale_statusline_format
ifa:mode==0" Errorletl:errors =l:counts.error +l:counts.style_error
returnl:errors ? printf(l:error_format,l:errors) : ''elseifa:mode==1" Warningletl:warnings =l:counts.warning +l:counts.style_warning
returnl:warnings ? printf(l:warning_format,l:warnings) : ''endifreturnl:counts.total ==0? l:no_errors: ''endfunction