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
81
82
83
84
85
86
87
88
89
90
91
92
" Set the statusline
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-07-10
" Initialize StatuslineMode highlight group
highlight! link StatuslineMode StatuslineModeNormal
function! StatusLine(sep)
" Reset the statusline
let s = ''
" Set highlight to StatuslineMode
let s .= '%#StatuslineMode# '
" Show mode
let m = mode()
if m ==# 'n'
highlight! link StatuslineMode StatuslineModeNormal
let s .= 'N'
elseif m ==# 'i'
highlight! link StatuslineMode StatuslineModeInsert
let s .= 'I'
elseif m ==# 'R'
highlight! link StatuslineMode StatuslineModeReplace
let s .= 'R'
elseif m ==? 'v' || m ==# ''
highlight! link StatuslineMode StatuslineModeVisual
let s .= 'V'
else
highlight! link StatuslineMode StatuslineModeNormal
let s .= toupper(m)
endif
" Set highlight to User1
let s .= ' %1* '
" Filename (truncated if necessary)
let s .= '%<%f'
" File flags (modified and read-only)
if &mod
let s .= ' +'
endif
if &ro
let s .= ' [RO]'
endif
" Set highlight to User2
let s .= ' %2* '
" Right justify
let s .= '%='
" Set highlight to User3
let s .= ' %3* '
" Show git branch, if available
if exists('*FugitiveHead')
let branch = FugitiveHead()
if branch != ''
let s .= branch . ' ' . a:sep . ' '
endif
endif
" Show line break style
if &ff ==# 'unix'
let s .= 'LF ' . a:sep . ' '
elseif &ff ==# 'dos'
let s .= 'CRLF ' . a:sep . ' '
elseif &ff ==# 'mac'
let s .= 'CR ' . a:sep . ' '
endif
" Show file type
if &ft ==# ''
let s .= 'none'
else
let s .= &ft
endif
" Set highlight to User4
let s .= ' %4* '
" Position in file
let s .= '%(%l:%c%V%) %P '
return s
endfunction
set laststatus=2
set noshowmode
set statusline=%!StatusLine('/')