Created
October 14, 2018 03:25
-
-
Save lartpang/09d63cbd669014f7e81291e5e6e100ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 设置状态行显示常用信息 | |
" %F 完整文件路径名 | |
" %m 当前缓冲被修改标记 | |
" %m 当前缓冲只读标记 | |
" %h 帮助缓冲标记 | |
" %w 预览缓冲标记 | |
" %Y 文件类型 | |
" %b ASCII值 | |
" %B 十六进制值 | |
" %l 行数 | |
" %v 列数 | |
" %p 当前行数占总行数的的百分比 | |
" %L 总行数 | |
" %{...} 评估表达式的值,并用值代替 | |
" %{"[fenc=".(&fenc==""?&enc:&fenc).((exists("+bomb") && &bomb)?"+":"")."]"} 显示文件编码 | |
" %{&ff} 显示文件类型 | |
function! Buf_total_num() | |
return len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) | |
endfunction | |
function! File_size(f) | |
let l:size = getfsize(expand(a:f)) | |
if l:size == 0 || l:size == -1 || l:size == -2 | |
return '' | |
endif | |
if l:size < 1024 | |
return l:size.' bytes' | |
elseif l:size < 1024*1024 | |
return printf('%.1f', l:size/1024.0).'k' | |
elseif l:size < 1024*1024*1024 | |
return printf('%.1f', l:size/1024.0/1024.0) . 'm' | |
else | |
return printf('%.1f', l:size/1024.0/1024.0/1024.0) . 'g' | |
endif | |
endfunction | |
function! LinterStatus() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? 'OK' : printf( | |
\ '%dW %dE', | |
\ all_non_errors, | |
\ all_errors | |
\) | |
endfunction | |
"buffer_num | |
set statusline=%<%1*[B-%n/%{Buf_total_num()}]%* | |
set statusline+=%2*\[%{File_size(@%)}%* | |
set statusline+=%3*->%F\]%* | |
set statusline+=%=%4*『%{exists('g:loaded_ale')?LinterStatus():'~'}』%{exists('g:loaded_fugitive')?fugitive#statusline():'~'}%* | |
set statusline+=%5*%m%r%y%* | |
set statusline+=%6*\[%{&ff}~%{\"\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"\|\"}%(%l:%c%V%)%* | |
set statusline+=%7*~%P\]%* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment