forked from Blacksuan19/init.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatusline.vim
237 lines (223 loc) · 11.3 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
" _____ __ __ __ _
" / ___/ / /_ ____ _ / /_ __ __ _____ / / (_) ____ ___
" \__ \ / __/ / __ `/ / __/ / / / / / ___/ / / / / / __ \ / _ \
" ___/ / / /_ / /_/ / / /_ / /_/ / (__ ) / /___ / / / / / // __/
" /____/ \__/ \__,_/ \__/ \__,_/ /____/ /_____//_/ /_/ /_/ \___/
set noshowmode
set laststatus=2
function! RedrawModeColors(mode) " {{{
" Normal mode
if a:mode == 'n'
hi CustomStatuslineAccent cterm=none gui=none ctermbg=none ctermfg=1 guibg=none guifg=#fc8993
hi CustomStatuslineAccentBody cterm=none gui=none ctermbg=1 ctermfg=0 guibg=#fc8993 guifg=#272c38
hi CustomStatuslineFilename cterm=none gui=none ctermbg=8 ctermfg=251 guibg=#272c38 guifg=#fc8993
" Insert mode
elseif a:mode == 'i'
hi CustomStatuslineAccent cterm=none gui=none ctermbg=none ctermfg=2 guibg=none guifg=#8de19f
hi CustomStatuslineAccentBody cterm=none gui=none ctermbg=2 ctermfg=0 guibg=#8de19f guifg=#272c38
hi CustomStatuslineFilename cterm=none gui=none ctermbg=8 ctermfg=251 guibg=#272c38 guifg=#8de19f
" Replace mode
elseif a:mode == 'R'
hi CustomStatuslineAccent cterm=none gui=none ctermbg=none ctermfg=1 guibg=none guifg=#A65169
hi CustomStatuslineAccentBody cterm=none gui=none ctermbg=1 ctermfg=0 guibg=#A65169 guifg=#272c38
hi CustomStatuslineFilename cterm=none gui=none ctermbg=8 ctermfg=251 guibg=#272c38 guifg=#A65169
" Visual mode
elseif a:mode == 'v' || a:mode == 'V' || a:mode == "\<C-V>"
hi CustomStatuslineAccent cterm=none gui=none ctermbg=none ctermfg=7 guibg=none guifg=#a7bdfb
hi CustomStatuslineAccentBody cterm=none gui=none ctermbg=7 ctermfg=0 guibg=#a7bdfb guifg=#272c38
hi CustomStatuslineFilename cterm=none gui=none ctermbg=8 ctermfg=7 guibg=#272c38 guifg=#a7bdfb
" Command mode
elseif a:mode == 'c'
hi CustomStatuslineAccent cterm=none gui=none ctermbg=none ctermfg=6 guibg=none guifg=#ee828c
hi CustomStatuslineAccentBody cterm=none gui=none ctermbg=6 ctermfg=0 guibg=#ee828c guifg=#272c38
hi CustomStatuslineFilename cterm=none gui=none ctermbg=8 ctermfg=6 guibg=#272c38 guifg=#ee828c
" Terminal mode
elseif a:mode == 't'
hi CustomStatuslineAccent cterm=none gui=none ctermbg=none ctermfg=3 guibg=none guifg=#fbdf90
hi CustomStatuslineAccentBody cterm=none gui=none ctermbg=3 ctermfg=0 guibg=#fbdb90 guifg=#272c38
hi CustomStatuslineFilename cterm=none gui=none ctermbg=8 ctermfg=3 guibg=#272c38 guifg=#fbdb90
endif
return ''
endfunction
" }}}
function! ModeIcon(mode) " {{{
" Normal mode
if a:mode == 'n'
return '煮'
" Insert mode
elseif a:mode == 'i'
return ' '
" Replace mode
elseif a:mode == 'R'
return ' '
" Visual mode
elseif a:mode == 'v'
return ' '
elseif a:mode == 'V'
return ' '
elseif a:mode == "\<C-V>"
return '礪'
" Command mode
elseif a:mode == 'c'
return '⌘ '
" Terminal mode
elseif a:mode == 't'
return 'ﰣ '
endif
return ''
endfunction
function! SetModifiedSymbol(modified) " {{{
if a:modified == 1
hi CustomStatuslineModifiedBody cterm=none gui=none ctermbg=1 ctermfg=0 guibg=#fc8993 guifg=#272c38
hi CustomStatuslineModified cterm=none gui=none ctermbg=none ctermfg=1 guibg=none guifg=#fc8993
else
hi CustomStatuslineModifiedBody cterm=none gui=none ctermbg=0 ctermfg=2 guibg=#1d212a guifg=#89e19c
hi CustomStatuslineModified cterm=none gui=none ctermbg=0 ctermfg=0 guibg=none guifg=#1d212a
endif
return ''
endfunction
function! FiletypeIcon()
return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() . ' ' : ' ') : ''
endfunction
function! SetFiletype(filetype) " {{{
if winwidth(0) > 70
hi CustomStatuslineFiletype cterm=none gui=none ctermbg=none ctermfg=5 guibg=none guifg=#d990cd
hi CustomStatuslineFiletypeIcon cterm=none gui=none ctermbg=5 ctermfg=0 guibg=#d990cd guifg=#272c38
hi CustomStatuslineFiletypeBody cterm=italic gui=italic ctermbg=8 ctermfg=5 guibg=#272c38 guifg=#d990cd
hi CustomStatuslineFiletypeSeparator cterm=none gui=none ctermbg=none ctermfg=8 guibg=none guifg=#272c38
if a:filetype == ''
return '-'
else
return a:filetype
endif
else
hi CustomStatuslineFiletype cterm=none gui=none ctermbg=none ctermfg=5 guibg=none guifg=#1d212a
hi CustomStatuslineFiletypeIcon cterm=none gui=none ctermbg=5 ctermfg=0 guibg=#1d212a guifg=#1d212a
hi CustomStatuslineFiletypeBody cterm=italic gui=italic ctermbg=5 ctermfg=5 guibg=#1d212a guifg=#1d212a
hi CustomStatuslineFiletypeSeparator cterm=none gui=none ctermbg=none ctermfg=5 guibg=none guifg=#1d212a
return ''
endif
endfunction
function GitBranchIcon()
if strlen(FugitiveHead())>0 && winwidth(0) > 70
hi CustomStatuslineGitbranch cterm=none gui=none ctermbg=none ctermfg=4 guibg=none guifg=#81d4ee
hi CustomStatuslineGitbranchIcon cterm=none gui=none ctermbg=4 ctermfg=0 guibg=#81d4ee guifg=#272c38
hi CustomStatuslineGitbranchBody cterm=none gui=none ctermbg=8 ctermfg=4 guibg=#272c38 guifg=#81d4ee
hi CustomStatuslineGitbranchSeparator cterm=none gui=none ctermbg=none ctermfg=8 guibg=none guifg=#272c38
return ' '
else
hi CustomStatuslineGitbranch cterm=none gui=none ctermbg=none ctermfg=0 guibg=none guifg=#1d212a
hi CustomStatuslineGitbranchIcon cterm=none gui=none ctermbg=0 ctermfg=0 guibg=#1d212a guifg=#1d212a
hi CustomStatuslineGitbranchBody cterm=none gui=none ctermbg=0 ctermfg=0 guibg=#1d212a guifg=#1d212a
hi CustomStatuslineGitbranchSeparator cterm=none gui=none ctermbg=none ctermfg=0 guibg=none guifg=#1d212a
return ''
endif
endfunction
function! Shiftwidth()
let fname = expand('%:t')
if ! &expandtab || fname == 'ControlP'
return '-'
endif
if &shiftwidth == 0
return &tabstop
else
return &shiftwidth
endif
endfunction
" Setup the colors
hi StatusLine cterm=none gui=none ctermbg=8 ctermfg=3 guibg=none guifg=none
hi CustomStatuslineSeparator cterm=none gui=none ctermbg=none ctermfg=8 guibg=none guifg=#272c38
hi CustomStatuslinePercentage ctermfg=0 cterm=NONE ctermbg=NONE
hi CustomStatuslinePercentageBody ctermbg=0 cterm=none ctermfg=6
hi CustomStatuslineTotalLines cterm=none gui=none ctermbg=none ctermfg=3 guibg=none guifg=#fbdf90
hi CustomStatuslineTotalLinesIcon cterm=none gui=none ctermbg=3 ctermfg=0 guibg=#fbdf90 guifg=#272c38
hi CustomStatuslineTotalLinesBody cterm=none gui=none ctermbg=8 ctermfg=3 guibg=#272c38 guifg=#fbdf90
hi CustomStatuslineTotalLinesSeparator cterm=none gui=none ctermbg=none ctermfg=8 guibg=none guifg=#272c38
hi CustomStatuslineInactiveDark cterm=none gui=none ctermbg=8 ctermfg=12 guibg=#44506c guifg=#a7bdfb
hi CustomStatuslineInactiveDarkSeparator cterm=none gui=none ctermbg=8 ctermfg=12 guibg=none guifg=#272c38
hi CustomStatuslineInactiveLight cterm=none gui=none ctermbg=8 ctermfg=12 guibg=none guifg=#44506c
hi CustomStatuslineInactiveLightSeparator cterm=none gui=none ctermbg=8 ctermfg=12 guibg=none guifg=#44506c
function! SetActiveStatusLine()
" Statusbar items
let statusline = "%{RedrawModeColors(mode())}"
" Left side items
" =======================
let statusline .= "%#CustomStatuslineAccent#"
let statusline .= "%#CustomStatuslineAccentBody#%{ModeIcon(mode())}"
let statusline .= "%#CustomStatuslineFilename#\ %t\ "
let statusline .= "%#CustomStatuslineSeparator#\ "
" Modified status
let statusline .= "%#CustomStatuslineModified#"
let statusline .= "%#CustomStatuslineModifiedBody#%{SetModifiedSymbol(&modified)}"
let statusline .= "%#CustomStatuslineModified#"
" Right side items
" =======================
let statusline .= "%="
" Git branch name
let statusline .= "%#CustomStatuslineGitbranch#"
let statusline .= "%#CustomStatuslineGitbranchIcon#%{GitBranchIcon()}"
let statusline .= "%#CustomStatuslineGitbranchBody#\ %{FugitiveHead()}"
let statusline .= "%#CustomStatuslineGitbranchSeparator#\ "
" Padding
let statusline .= "\ "
" Current line / total number of lines
let statusline .= "%#CustomStatuslineTotalLines#"
let statusline .= "%#CustomStatuslineTotalLinesIcon# "
let statusline .= "%#CUSTomStatuslineTotalLinesBody#\ %l"
let statusline .= "\/\%#CUSTomStatuslineTotalLinesBody#%L"
let statusline .= "%#CustomStatuslineTotalLinesSeparator#"
" Padding
let statusline .= "\ "
" Filetype
let statusline .= "%#CustomStatuslineFiletype#"
let statusline .= "%#CustomStatuslineFiletypeIcon#%{FiletypeIcon()}"
let statusline .= "%#CustomStatuslineFiletypeBody#\ %{SetFiletype(&filetype)}"
let statusline .= "%#CustomStatuslineFiletypeSeparator#\ "
return statusline
endfunction
function! SetInactiveStatusLine()
" Statusbar items
let statusline = "%{RedrawModeColors(mode())}"
" Left side items
" =======================
let statusline .= "%#CustomStatuslineAccent#"
let statusline .= "%#CustomStatuslineAccentBody#%{ModeIcon(mode())}"
let statusline .= "%#CustomStatuslineFilename#\ %t\ "
let statusline .= "%#CustomStatuslineSeparator#\ "
" Modified status
let statusline .= "%#CustomStatuslineModified#"
let statusline .= "%#CustomStatuslineModifiedBody#%{SetModifiedSymbol(&modified)}"
let statusline .= "%#CustomStatuslineModified#"
" Right side items
" =======================
let statusline .= "%="
" Git branch name
let statusline .= "%#CustomStatuslineGitbranch#"
let statusline .= "%#CustomStatuslineGitbranchIcon#%{GitBranchIcon()}"
let statusline .= "%#CustomStatuslineGitbranchBody#\ %{FugitiveHead()}"
let statusline .= "%#CustomStatuslineGitbranchSeparator#\ "
" Padding
let statusline .= "\ "
" Current line / total number of lines
let statusline .= "%#CustomStatuslineTotalLines#"
let statusline .= "%#CustomStatuslineTotalLinesIcon# "
let statusline .= "%#CUSTomStatuslineTotalLinesBody#\ %l"
let statusline .= "\/\%#CUSTomStatuslineTotalLinesBody#%L"
let statusline .= "%#CustomStatuslineTotalLinesSeparator#"
" Padding
let statusline .= "\ "
" Filetype
let statusline .= "%#CustomStatuslineFiletype#"
let statusline .= "%#CustomStatuslineFiletypeIcon#%{FiletypeIcon()}"
let statusline .= "%#CustomStatuslineFiletypeBody#\ %{SetFiletype(&filetype)}"
let statusline .= "%#CustomStatuslineFiletypeSeparator#\ "
return statusline
endfunction
augroup vimrc-statusline
autocmd!
autocmd WinEnter * setlocal statusline=%!SetActiveStatusLine()
autocmd BufEnter * setlocal statusline=%!SetActiveStatusLine()
autocmd WinNew * setlocal statusline=%!SetActiveStatusLine()
autocmd WinLeave * setlocal statusline=%!SetActiveStatusLine()
augroup END
setlocal statusline=%!SetActiveStatusLine()