-
Notifications
You must be signed in to change notification settings - Fork 1
/
statusline.vim
80 lines (75 loc) · 2.05 KB
/
statusline.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function! LinterStatus() abort
if !exists(":ALEInfo")
return
endif
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
" function! FugitiveStatus() abort
" if !exists(":Git")
" return
" endif
" return FugitiveStatusline()
" endfunction
function! GitBranch()
let l:cmd="git rev-parse --abbrev-ref HEAD 2>/dev/null | fold -w30 | head -n1"
let l:branch = trim(system(l:cmd))
if empty(l:branch)
return 'NOT IN GIT'
endif
return l:branch
endfunction
" got from https://jdhao.github.io/2019/11/03/vim_custom_statusline/
let g:currentmode={
\ 'n' : 'NORMAL',
\ 'v' : 'VISUAL',
\ 'V' : 'V·Line',
\ "\<C-V>" : 'V·Block',
\ 'i' : 'INSERT',
\ 'R' : 'R',
\ 'Rv' : 'V·Replace',
\ 'c' : 'Command',
\ 't' : 'Term',
\}
set statusline=
" use User5 highlight group
set statusline+=%2*
set statusline+=%{toupper(g:currentmode[mode()])}
" reset highlight group
set statusline+=%0*
" a space
set statusline+=\ %f
" modified flag
set statusline+=%m
" set statusline+=[%{LinterStatus()}]
" left/right separator
set statusline+=%=
set statusline+=%2* " start User2 highlight group
" cursor line/total lines
set statusline+=\ \[%l\]\ /\ %L
set statusline+=\ \|\ Col:\ %c
" reset highlight group
set statusline+=\ %0*
" filetype
set statusline+=\ %y
set statusline+=[
" file encoding
set statusline+=%{strlen(&fileencoding)?&fileencoding:'none'}\|
" file format
set statusline+=%{&fileformat}
" BOM
set statusline+=%{&bomb?'\|BOM':''}
set statusline+=]
" help file flag
set statusline+=%h
" read only flag
set statusline+=%r
set statusline+=\ %1* " start User1 highlight group
set statusline+=\[%{GitBranch()}\]
set statusline+=%0*