-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvimrc
More file actions
1167 lines (987 loc) · 42.1 KB
/
vimrc
File metadata and controls
1167 lines (987 loc) · 42.1 KB
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" vim: set filetype=vim expandtab ts=2 sts=2 sw=2 :
scriptencoding utf-8
" Varible {
" 定义键映射前缀: 统一按键前缀, 避免键冲突
" 全局键映射前缀 <Leader>, 默认为 '\', 这里设置为 <Space>
let g:mapleader = "\<Space>"
" 文件类型插件的键映射前缀 <LocalLeader>
let g:maplocalleader = ","
" 是否启用鼠标(鼠标滚动, 点击位置): 1 为启用 0 为禁用
let g:enableMouse = 1
" 当超出显示区域, 超出区域是否下一行显示, 1 为不折行, 0 为折行
" let g:noWrapLine = 1
" 一个 TAB 占几个空格
let g:tabspace = 2
" 将输入的 Tab 自动展开成空格, 0 为展开, 1 为不展开
" let g:noExpandtab = 0
" 仅有在 noExpandtabList 里的文件类型不进行输入的 Tab 自动转化为相应数量空格
let g:noExpandtabList = ['markdown']
" 启用回退: 1 为 启用, 0 为禁用
" 可视 Mode 下: u 为撤销, ctrl+r 为恢复
let g:enableUndo = 1
" 增强状态栏: 1 为增强, 0 为默认
let g:enableStatusline = 1
" 增强斜体: 1 为增强, 0 为默认
" 需要终端支持, 终端若不支持并且显示异常, 那么注释此选项可恢复正常
" let g:enableItalic = 1
"}
let s:expandfile = expand('%:r')
let s:resolvefile = resolve(s:expandfile)
let s:resolvePath = fnamemodify(s:resolvefile, ':p:h:s?/$??')
" 是否为 GUi VIM
let g:gui_running = has('gui_running')
set nocompatible " 关掉兼容模式: 避免 vi 下的一些功能操作
set nomodeline " 禁用 modeline, 避免文本中出现的 vim 被认为是modeline
" 避免续行效应
let s:save_cpo = &cpo
set cpo&vim
" config {
" http://edyfox.codecarver.org/html/vim_fileencodings_detection.html
" encoding {
set encoding=utf-8 " Set default encoding
set termencoding=utf-8 " 输出到终端采用的编码类型
" 按顺序使用一下编码尝试解码
" 如果解码成功, fileencoding 被设置为相应编码
" 如果解码失败, 则继续下一个编码尝试解码
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
" }
" color {
set t_Co=256 " 开启 256 色
" http://stackoverflow.com/questions/6427650/vim-in-tmux-background-color-changes-when-paging/15095377#15095377
set t_ut= " 修复 tmux 下背景色渲染正确的问题
" }
" line number {
set number " 行号
" Relative numbers on
if exists('&relativenumber') | set relativenumber | endif
" }
" cursor {
set cursorline " 行光标线
" set cursorcolumn " 列光标线
"}
" Change cursor shape for iTerm2 on macOS {
" inside iTerm2
if $TERM_PROGRAM =~# 'iTerm'
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
if exists('&t_SR')
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
endif
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" inside tmux
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
if exists('&t_SR')
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
endif
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
endif
" }
" 括号匹配 {
set showmatch " 当输入右括号, 闪烁匹配的左括号
set matchtime=2 " Show matching time, 单位为 1/10s, 默认 500ms
" }
" 断行设置 {
set textwidth=80 " 一行显示 80 字符
if exists('g:noWrapLine') && g:noWrapLine
set nowrap
set sidescroll=6 " 当光标达到水平极端时 移动的列数
else
set wrap " 设置自动折行, 超过 textwidth, 则折行
endif
set linebreak " 不在单词中间断行
set fo+=mB " 断行对汉字的支持
set whichwrap+=<,>,h,l " 允许Normal 或 Visual 模式下左右移动跨越行边界
" }
" list {
set listchars=tab:▸\ ,trail:·,precedes:«,extends:»,eol:↵
set nolist " 隐藏不可见字符
"}
" fold {
set foldmethod=indent " 折叠方式
set nofoldenable " 不自动折叠
set foldcolumn=1 " 在行号前空出一列的宽度
" }
" bottom status bar {
set report=0 " Always report changed lines, such as 1 line yanked, 2 fewer lines
set laststatus=2 " 总是显示状态栏
set display=lastline " Show as much as possible of the last line
set showmode " 左下角显示 vim Mode, 没有显示为常规模式
set ruler " 右下角显示光标的行列信息
set showcmd " 右下角显示 vim 输入指令
set wildmenu " 开启 Vim 自身命令行模式智能补全
set wildmode=list:longest,full " http://vimcdoc.sourceforge.net/doc/options.html#'wildmode'
" <EOL> {
set fileformats=unix,dos,mac " 给出换行符的格式, 具体: help fileformats
" }
"}
" syntax {
syntax on " Syntax highlighting
filetype plugin indent on " Automatically detect file types
" }
" indent {
filetype indent on " 自适应不同语言的智能缩进
set autoindent
set smartindent " 智能对齐
" set cindent
" }
" TAB {
let &tabstop=g:tabspace " 一个 <Tab> 占据的空格数
let &shiftwidth=g:tabspace " cindent, autoindent、<< 和 >> 缩进的空格数
let &softtabstop=g:tabspace " Tab 将补齐 n 个空格, <Backspace> 删除 n 个空格
set smarttab
" 将输入的 Tab 自动展开成空格
if !exists('g:noExpandtab') || !g:noExpandtab
if !exists('g:noExpandtabList')
let g:noExpandtabList = []
endif
autocmd InsertEnter * if index(g:noExpandtabList, &ft) < 0 | set expandtab | endif
endif
"}
" 设置 backspace 的行为
" indent : 允许删除自动插入的缩进
" eol: 允许删除到上一行
" start: 允许删除到行首
set backspace=indent,eol,start
" search {
set hlsearch " Highlight search results
set incsearch " 开启实时搜索
set ignorecase " 搜索时大小写不敏感
set smartcase " 如果搜索字符串里包含大写字母,则精确匹配
"}
" mouse {
if exists('g:enableMouse') && g:enableMouse
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
set ttymouse=xterm2
set scrolljump=1 " 当光标达到上端或下端时 翻滚的行数
set so=6 " 上下滚行时空余6行
endif
" }
" use system copyboard {
if has('unnamedplus')
set clipboard=unnamedplus,unnamed
else
set clipboard+=unnamed
endif
" }
" http://vimcdoc.sourceforge.net/doc/undo.html
" undo - 无限回退 {
if exists('g:enableUndo') && g:enableUndo
if has('persistent_undo')
let s:undodir=$HOME.'/.vim/undodir'
if !isdirectory(s:undodir)
if exists("*mkdir")
call mkdir(s:undodir, 'p', 0755)
else
echom '[undo]: can not create dir "'.s:undodir.'" to store undo file, you need create it manually'
endif
endif
set undodir=~/.vim/undodir " 指定撤销文件路径(默认撤销文件通常保存在文件本身相同的目录里)
set undofile " Persistent undo
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
endif
" }
" 性能 {
set lazyredraw " 解决某些类型的文件由于syntax导致vim反应过慢的问题
set ttyfast " Faster redrawing, 有助于 xterm 和其他终端上使用鼠标来进行复制/粘贴
" }
" other {
set linespace=0 " No extra spaces between rows
set shortmess=atOI " 启动时不显示捐助乌干达儿童的提示
set autoread " Automatically read a file changed outside of vim
set autowrite " Automatically write a file when leaving a modified buffer
set complete-=i " Exclude files completion
set history=10000 " Maximum history record
set viminfo+=! " Viminfo include !
"}
if g:gui_running
set guioptions-=r " Hide the right scrollbar
set guioptions-=L " Hide the left scrollbar
set guioptions-=T
set guioptions-=e
set shortmess+=c
" No annoying sound on errors
set noerrorbells
set novisualbell
set visualbell t_vb=
endif
" } end config
if has('autocmd')
augroup MINI_VIM_BASIC
autocmd!
" Restore cursor position when opening file
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" 当退出最后一个可可编辑文件时, 退出 vim
autocmd BufEnter * call MyLastWindow()
function! MyLastWindow()
" if the window is quickfix/locationlist go on
if &buftype ==# 'quickfix' || &buftype ==# 'locationlist'
" if this window is last on screen quit without warning
if winbufnr(2) == -1
quit!
endif
endif
endfunction
" 当大于 10000000 时, 关闭语法增强
autocmd BufReadPre *
\ if getfsize(expand("%")) > 10000000 |
\ syntax off |
\ endif
augroup END
endif
" space-vim-dark {
if !exists('g:colors_name')
" Vim color file
"
" Author: Liu-Cheng Xu
" URL: https://github.com/liuchengxu/space-vim-dark
"
" Note: Inspired by spacemacs-dark theme
hi clear
if v:version > 580
" no guarantees for version 5.8 and below, but this makes it stop
" complaining
hi clear
if exists('g:syntax_on')
syntax reset
endif
endif
let g:colors_name='space-vim-dark'
" refer to http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
let s:color256 = {
\ 0 : '#000000', 1 : '#800000', 2 : '#008000', 3 : '#808000', 4 : '#000080', 5 : '#800080', 6 : '#008080' , 7 : '#c0c0c0',
\ 8 : '#808080', 9 : '#ff0000', 10 : '#00ff00', 11 : '#ffff00', 12 : '#0000ff', 13 : '#ff00ff', 14 : '#00ffff', 15 : '#ffffff',
\ 16 : '#000000', 17 : '#00005f', 18 : '#000087', 19 : '#0000af', 20 : '#0000d7', 21 : '#0000ff',
\ 22 : '#005f00', 23 : '#005f5f', 24 : '#005f87', 25 : '#005faf', 26 : '#005fd7', 27 : '#005fff',
\ 28 : '#008700', 29 : '#00875f', 30 : '#008787', 31 : '#0087af', 32 : '#0087d7', 33 : '#0087ff',
\ 34 : '#00af00', 35 : '#00af5f', 36 : '#00af87', 37 : '#00afaf', 38 : '#00afd7', 39 : '#00afff',
\ 40 : '#00d700', 41 : '#00d75f', 42 : '#00d787', 43 : '#00d7af', 44 : '#00d7d7', 45 : '#00d7ff',
\ 46 : '#00ff00', 47 : '#00ff5f', 48 : '#00ff87', 49 : '#00ffaf', 50 : '#00ffd7', 51 : '#00ffff',
\ 52 : '#5f0000', 53 : '#5f005f', 54 : '#5f0087', 55 : '#5f00af', 56 : '#5f00d7', 57 : '#5f00ff',
\ 58 : '#5f5f00', 59 : '#5f5f5f', 60 : '#5f5f87', 61 : '#5f5faf', 62 : '#5f5fd7', 63 : '#5f5fff',
\ 64 : '#5f8700', 65 : '#5f875f', 66 : '#5f8787', 67 : '#5f87af', 68 : '#5f87d7', 69 : '#5f87ff',
\ 70 : '#5faf00', 71 : '#5faf5f', 72 : '#5faf87', 73 : '#5fafaf', 74 : '#5fafd7', 75 : '#5fafff',
\ 76 : '#5fd700', 77 : '#5fd75f', 78 : '#5fd787', 79 : '#5fd7af', 80 : '#5fd7d7', 81 : '#5fd7ff',
\ 82 : '#5fff00', 83 : '#5fff5f', 84 : '#5fff87', 85 : '#5fffaf', 86 : '#5fffd7', 87 : '#5fffff',
\ 88 : '#870000', 89 : '#87005f', 90 : '#870087', 91 : '#8700af', 92 : '#8700d7', 93 : '#8700ff',
\ 94 : '#875f00', 95 : '#875f5f', 96 : '#875f87', 97 : '#875faf', 98 : '#875fd7', 99 : '#875fff',
\ 100 : '#878700', 101 : '#87875f', 102 : '#878787', 103 : '#8787af', 104 : '#8787d7', 105 : '#8787ff',
\ 106 : '#87af00', 107 : '#87af5f', 108 : '#87af87', 109 : '#87afaf', 110 : '#87afd7', 111 : '#87afff',
\ 112 : '#87d700', 113 : '#87d75f', 114 : '#87d787', 115 : '#87d7af', 116 : '#87d7d7', 117 : '#87d7ff',
\ 118 : '#87ff00', 119 : '#87ff5f', 120 : '#87ff87', 121 : '#87ffaf', 122 : '#87ffd7', 123 : '#87ffff',
\ 124 : '#af0000', 125 : '#af005f', 126 : '#af0087', 127 : '#af00af', 128 : '#af00d7', 129 : '#af00ff',
\ 130 : '#af5f00', 131 : '#af5f5f', 132 : '#af5f87', 133 : '#af5faf', 134 : '#af5fd7', 135 : '#af5fff',
\ 136 : '#af8700', 137 : '#af875f', 138 : '#af8787', 139 : '#af87af', 140 : '#af87d7', 141 : '#af87ff',
\ 142 : '#afaf00', 143 : '#afaf5f', 144 : '#afaf87', 145 : '#afafaf', 146 : '#afafd7', 147 : '#afafff',
\ 148 : '#afd700', 149 : '#afd75f', 150 : '#afd787', 151 : '#afd7af', 152 : '#afd7d7', 153 : '#afd7ff',
\ 154 : '#afff00', 155 : '#afff5f', 156 : '#afff87', 157 : '#afffaf', 158 : '#afffd7', 159 : '#afffff',
\ 160 : '#d70000', 161 : '#d7005f', 162 : '#d70087', 163 : '#d700af', 164 : '#d700d7', 165 : '#d700ff',
\ 166 : '#d75f00', 167 : '#d75f5f', 168 : '#d75f87', 169 : '#d75faf', 170 : '#d75fd7', 171 : '#d75fff',
\ 172 : '#d78700', 173 : '#d7875f', 174 : '#d78787', 175 : '#d787af', 176 : '#d787d7', 177 : '#d787ff',
\ 178 : '#d7af00', 179 : '#d7af5f', 180 : '#d7af87', 181 : '#d7afaf', 182 : '#d7afd7', 183 : '#d7afff',
\ 184 : '#d7d700', 185 : '#d7d75f', 186 : '#d7d787', 187 : '#d7d7af', 188 : '#d7d7d7', 189 : '#d7d7ff',
\ 190 : '#d7ff00', 191 : '#d7ff5f', 192 : '#d7ff87', 193 : '#d7ffaf', 194 : '#d7ffd7', 195 : '#d7ffff',
\ 196 : '#ff0000', 197 : '#ff005f', 198 : '#ff0087', 199 : '#ff00af', 200 : '#ff00d7', 201 : '#ff00ff',
\ 202 : '#ff5f00', 203 : '#ff5f5f', 204 : '#ff5f87', 205 : '#ff5faf', 206 : '#ff5fd7', 207 : '#ff5fff',
\ 208 : '#ff8700', 209 : '#ff875f', 210 : '#ff8787', 211 : '#ff87af', 212 : '#ff87d7', 213 : '#ff87ff',
\ 214 : '#ffaf00', 215 : '#ffaf5f', 216 : '#ffaf87', 217 : '#ffafaf', 218 : '#ffafd7', 219 : '#ffafff',
\ 220 : '#ffd700', 221 : '#ffd75f', 222 : '#ffd787', 223 : '#ffd7af', 224 : '#ffd7d7', 225 : '#ffd7ff',
\ 226 : '#ffff00', 227 : '#ffff5f', 228 : '#ffff87', 229 : '#ffffaf', 230 : '#ffffd7', 231 : '#ffffff',
\
\ 232 : '#080808', 233 : '#121212', 234 : '#1c1c1c', 235 : '#262626', 236 : '#303030', 237 : '#3a3a3a',
\ 238 : '#444444', 239 : '#4e4e4e', 240 : '#585858', 241 : '#606060', 242 : '#666666', 243 : '#767676',
\ 244 : '#808080', 245 : '#8a8a8a', 246 : '#949494', 247 : '#9e9e9e', 248 : '#a8a8a8', 249 : '#b2b2b2',
\ 250 : '#bcbcbc', 251 : '#c6c6c6', 252 : '#d0d0d0', 253 : '#dadada', 254 : '#e4e4e4', 255 : '#eeeeee',
\ }
" ========|===========
" Red | 160 168
" Blue | 67 68 111
" Yellow | 114 179
" Orange | 173 178
" Purple | 140
" Magenta | 128
" ========|===========
let s:colors = {
\ 16: '#292b2e', 24: '#3C8380', 28: '#c269fe', 30: '#2aa1ae', 36: '#20af81', 40: '#00ff00',
\ 59: '#FF73B9', 68: '#4f97d7', 75: '#FF62B0', 76: '#86dc2f', 81: '#f9bb00', 88: '#330033',
\ 104: '#df90ff', 114: '#67b11d', 128: '#e76a49', 135: '#B7B7FF', 136: '#dc752f', 139: '#d698fe',
\ 140: '#b888e2', 141: '#9a9aba', 151: '#74BAAC', 160: '#e0211d', 161: '#E469FE', 167: '#ce537a',
\ 168: '#ce537a', 169: '#bc6ec5', 171: '#6094DB', 173: '#e18254', 176: '#E697E6', 177: '#D881ED',
\ 178: '#d1951d', 179: '#d4b261', 196: '#e0211d', 204: '#ce537a', 207: '#FF68DD', 214: '#FF4848',
\ 218: '#d19a66', 225: '#FFC8C8', 229: '#fff06a', 233: '#303030', 234: '#212026', 235: '#292b2e',
\ 236: '#34323e', 238: '#544a65', 241: '#534b5d', 243: '#65737e', 244: '#b4d1b6',
\ }
function! s:hi(item, fg, bg, cterm, gui)
let l:fg = empty(a:fg) ? '' : printf('ctermfg=%d guifg=%s', a:fg, get(s:colors, a:fg, s:color256[a:fg]))
let l:bg = empty(a:bg) ? '' : printf('ctermbg=%d guibg=%s', a:bg, get(s:colors, a:bg, s:color256[a:bg]))
let l:style = printf('cterm=%s gui=%s', a:cterm, a:gui)
execute 'hi '.a:item.' '.l:fg.' '.l:bg.' '.l:style
endfunction
let s:fg = 249
let s:bg = get(g:, 'space_vim_dark_background', 235)
let s:bias = s:bg - 235
let s:bg0 = s:bg - 1
let s:bg1 = s:bg + 1
let s:bg2 = s:bg + 2
let s:bg3 = s:bg + 3
let s:bg4 = s:bg + 4
" call s:hi(item, fg, bg, cterm, gui)
call s:hi('Normal' , 249 , s:bg , 'None' , 'None')
call s:hi('Cursor' , 235 , 178 , 'bold' , 'bold')
call s:hi('LineNr' , 238+s:bias , s:bg0 , 'None' , 'None')
call s:hi('CursorLine' , '' , s:bg0 , 'None' , 'None')
call s:hi('CursorLineNr' , 134 , s:bg0 , 'None' , 'None')
call s:hi('CursorColumn' , '' , s:bg0 , 'None' , 'None')
call s:hi('ColorColumn' , '' , s:bg0 , 'None' , 'None')
" bug. opposite here.
call s:hi('StatusLine' , 140 , s:bg2 , 'None' , 'None')
call s:hi('StatusLineNC' , 242 , s:bg1 , 'None' , 'None')
call s:hi('StatusLineTerm' , 140 , s:bg2 , 'bold' , 'bold')
call s:hi('StatusLineTermNC' , 244 , s:bg1 , 'bold' , 'bold')
call s:hi('TabLine' , 66 , s:bg3 , 'None' , 'None')
call s:hi('TabLineSel' , 178 , s:bg4 , 'None' , 'None')
call s:hi('TabLineFill' , 145 , s:bg2 , 'None' , 'None')
call s:hi('WildMenu' , 214 , s:bg3 , 'None' , 'None')
call s:hi('Boolean' , 178 , '' , 'None' , 'None')
call s:hi('Character' , 75 , '' , 'None' , 'None')
call s:hi('Number' , 176 , '' , 'None' , 'None')
call s:hi('Float' , 135 , '' , 'None' , 'None')
call s:hi('String' , 36 , '' , 'None' , 'None')
call s:hi('Conditional' , 68 , '' , 'bold' , 'bold')
call s:hi('Constant' , 218 , '' , 'None' , 'None')
call s:hi('Debug' , 225 , '' , 'None' , 'None')
call s:hi('Define' , 177 , '' , 'None' , 'None')
call s:hi('Delimiter' , 151 , '' , 'None' , 'None')
call s:hi('DiffAdd' , '' , 24 , 'None' , 'None')
call s:hi('DiffChange' , 181 , 239 , 'None' , 'None')
call s:hi('DiffDelete' , 162 , 53 , 'None' , 'None')
call s:hi('DiffText' , '' , 102 , 'None' , 'None')
call s:hi('Exception' , 204 , '' , 'bold' , 'bold')
call s:hi('Function' , 169 , '' , 'bold' , 'bold')
call s:hi('Identifier' , 167 , '' , 'None' , 'None')
call s:hi('Ignore' , 244 , '' , 'None' , 'None')
call s:hi('Operator' , 111 , '' , 'None' , 'None')
call s:hi('FoldColumn' , 67 , s:bg1 , 'None' , 'None')
call s:hi('Folded' , 133 , s:bg1 , 'bold' , 'bold')
call s:hi('PreCondit' , 139 , '' , 'None' , 'None')
call s:hi('PreProc' , 176 , '' , 'None' , 'None')
call s:hi('Question' , 81 , '' , 'None' , 'None')
call s:hi('Directory' , 67 , '' , 'bold' , 'bold')
call s:hi('Repeat' , 68 , '' , 'bold' , 'bold')
call s:hi('Keyword' , 68 , '' , 'bold' , 'bold')
call s:hi('Statement' , 68 , '' , 'None' , 'None')
call s:hi('Structure' , 68 , '' , 'bold' , 'bold')
call s:hi('Label' , 104 , '' , 'None' , 'None')
call s:hi('Macro' , 140 , '' , 'None' , 'None')
call s:hi('Type' , 68 , '' , 'None' , 'None')
call s:hi('Typedef' , 68 , '' , 'None' , 'None')
call s:hi('Underlined' , '' , '' , 'underline' , 'underline')
call s:hi('Search' , 16 , 76 , 'bold' , 'bold')
call s:hi('IncSearch' , 16 , 167 , 'bold' , 'bold')
call s:hi('MatchParen', 40 , s:bg0 , 'bold,underline', 'bold,underline')
call s:hi('ModeMsg' , 229 , '' , 'None' , 'None')
" Popup menu
call s:hi('Pmenu' , 141 , s:bg1 , 'None' , 'None')
call s:hi('PmenuSel' , 251 , 97 , 'None' , 'None')
call s:hi('PmenuSbar' , 28 , 233 , 'None' , 'None')
call s:hi('PmenuThumb' , 160 , 97 , 'None' , 'None')
" SignColumn may relate to ale sign
call s:hi('SignColumn' , 118 , s:bg , 'None' , 'None')
call s:hi('Todo' , 172 , s:bg , 'bold' , 'bold')
" VertSplit consistent with normal background to hide it
call s:hi('VertSplit' , s:bg0 , '' , 'None' , 'None')
call s:hi('Warning' , 136 , '' , 'bold' , 'bold')
call s:hi('WarningMsg' , 136 , '' , 'bold' , 'bold')
call s:hi('Error' , 160 , s:bg , 'bold' , 'bold')
call s:hi('ErrorMsg' , 196 , s:bg , 'bold' , 'bold')
call s:hi('Special' , 169 , '' , 'None' , 'None')
call s:hi('SpecialKey' , 59 , '' , 'None' , 'None')
call s:hi('SpecialChar' , 171 , '' , 'bold' , 'bold')
call s:hi('SpecialComment' , 243 , '' , 'None' , 'None')
call s:hi('SpellBad' , 168 , '' , 'underline' , 'undercurl')
call s:hi('SpellCap' , 110 , '' , 'underline' , 'undercurl')
call s:hi('SpellLocal' , 253 , '' , 'underline' , 'undercurl')
call s:hi('SpellRare' , 218 , '' , 'underline' , 'undercurl')
call s:hi('Tag' , 161 , '' , 'None' , 'None')
call s:hi('Title' , 176 , '' , 'None' , 'None')
call s:hi('StorageClass' , 178 , '' , 'bold' , 'bold')
call s:hi('Comment' , 30 , '' , 'None' , 'italic')
call s:hi('Visual' , '' , s:bg3 , 'None' , 'None')
call s:hi('VisualNOS' , '' , s:bg3 , 'None' , 'None')
" tilde group
call s:hi('NonText' , 241 , '' , 'None' , 'None')
call s:hi('Terminal' , 249 , s:bg , 'None' , 'None')
call s:hi('diffAdded' , 36 , '' , 'None' , 'None')
call s:hi('diffRemoved' , 167 , '' , 'None' , 'None')
hi MatchParen guibg=NONE
hi SignColumn guibg=NONE
hi link qfLineNr Type
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Language
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" markdown
call s:hi('markdownH1' , 68 , '' , 'bold' , 'bold')
call s:hi('markdownH2' , 36 , '' , 'bold' , 'bold')
call s:hi('markdownH3' , 114 , '' , 'bold' , 'bold')
call s:hi('markdownH4' , 178 , '' , 'bold' , 'bold')
call s:hi('markdownH5' , 68 , '' , 'None' , 'None')
call s:hi('markdownH6' , 36 , '' , 'None' , 'None')
call s:hi('mkdCode' , 114 , '' , 'None' , 'None')
call s:hi('mkdItalic' , 36 , '' , 'None' , 'italic')
" c
call s:hi('cConstant' , 178 , '' , 'none' , 'none')
call s:hi('cCustomClass' , 167 , '' , 'bold' , 'bold')
" cpp
call s:hi('cppSTLexception', 199, '', 'bold', 'bold')
call s:hi('cppSTLnamespace', 178, '', 'bold', 'bold')
" css
call s:hi('cssTagName' , 68 , '' , 'bold' , 'bold')
call s:hi('cssProp' , 169 , '' , 'bold' , 'bold')
" dot
call s:hi('dotKeyChar' , 176 , '' , 'none' , 'none')
call s:hi('dotType' , 178 , '' , 'none' , 'none')
" sh
call s:hi('shSet' , 68 , '' , 'bold' , 'bold')
call s:hi('shLoop' , 68 , '' , 'bold' , 'bold')
call s:hi('shFunctionKey' , 68 , '' , 'bold' , 'bold')
call s:hi('shTestOpr' , 178 , '' , 'none' , 'none')
" solidity
call s:hi('solContract' , 178 , '' , 'bold' , 'bold')
call s:hi('solContractName' , 168 , '' , 'bold' , 'bold')
call s:hi('solBuiltinType' , 176 , '' , 'none' , 'none')
" vimL
call s:hi('vimLet' , 68 , '' , 'bold' , 'bold')
call s:hi('vimFuncKey' , 68 , '' , 'bold' , 'bold')
call s:hi('vimCommand' , 68 , '' , 'bold' , 'bold')
call s:hi('vimGroup' , 67 , '' , 'bold' , 'bold')
call s:hi('vimHiGroup' , 67 , '' , 'bold' , 'bold')
" rust
call s:hi('rustKeyword' , 68 , '' , 'bold' , 'bold')
call s:hi('rustModPath' , 68 , '' , 'none' , 'none')
call s:hi('rustTrait' , 168 , '' , 'bold' , 'bold')
" json
call s:hi('jsonStringSQError', 160, '', 'none', 'none')
" xml
call s:hi('xmlTag' , 167 , '' , 'none' , 'none')
call s:hi('xmlEndTag' , 167 , '' , 'none' , 'none')
call s:hi('xmlTagName' , 167 , '' , 'none' , 'none')
" go
call s:hi('goType' , 176 , '' , 'none' , 'none')
call s:hi('goFloat' , 135 , '' , 'none' , 'none')
call s:hi('goField' , 68 , '' , 'none' , 'none')
call s:hi('goTypeName' , 169 , '' , 'bold' , 'bold')
call s:hi('goFunction' , 169 , '' , 'bold' , 'bold')
call s:hi('goMethodCall' , 168 , '' , 'bold' , 'bold')
call s:hi('goReceiverType' , 114 , '' , 'none' , 'none')
call s:hi('goFunctionCall' , 169 , '' , 'bold' , 'bold')
call s:hi('goFormatSpecifier' , 68 , '' , 'none' , 'none')
call s:hi('goTypeConstructor' , 178 , '' , 'none' , 'none')
call s:hi('goPredefinedIdentifiers' , 140 , '' , 'none' , 'none')
" make
call s:hi('makeCommands' , 68 , '' , 'none' , 'none')
call s:hi('makeSpecTarget' , 68 , '' , 'bold' , 'bold')
" java
call s:hi('rustScopeDecl' , 68 , '' , 'bold' , 'bold')
call s:hi('javaClassDecl' , 168 , '' , 'bold' , 'bold')
" scala
call s:hi('scalaKeyword' , 68 , '' , 'bold' , 'bold')
call s:hi('scalaNameDefinition' , 68 , '' , 'bold' , 'bold')
" ruby
call s:hi('rubyClass' , 68 , '' , 'bold' , 'bold')
call s:hi('rubyDefine' , 68 , '' , 'bold' , 'bold')
call s:hi('rubyInterpolationDelimiter' , 176 , '' , 'none' , 'none')
" html
hi link htmlSpecialTagName Tag
call s:hi('htmlItalic' , 36 , '' , 'None' , 'italic')
" python-mode
call s:hi('pythonLambdaExpr' , 105 , '' , 'none' , 'none')
call s:hi('pythonClass' , 207 , '' , 'bold' , 'bold')
call s:hi('pythonParameters' , 147 , '' , 'none' , 'none')
call s:hi('pythonParam' , 108 , '' , 'none' , 'none')
call s:hi('pythonBrackets' , 183 , '' , 'none' , 'none')
call s:hi('pythonClassParameters' , 111 , '' , 'none' , 'none')
call s:hi('pythonBuiltinType' , 68 , '' , 'none' , 'none')
call s:hi('pythonBuiltinObj' , 71 , '' , 'bold' , 'bold')
call s:hi('pythonBuiltinFunc' , 169 , '' , 'bold' , 'bold')
call s:hi('pythonOperator' , 68 , '' , 'bold' , 'bold')
call s:hi('pythonInclude' , 68 , '' , 'bold' , 'bold')
call s:hi('pythonSelf' , 68 , '' , 'bold' , 'bold')
call s:hi('pythonStatement' , 68 , '' , 'bold' , 'bold')
call s:hi('pythonDottedName' , 169 , '' , 'bold' , 'bold')
call s:hi('pythonDecorator' , 169 , '' , 'bold' , 'bold')
call s:hi('pythonException' , 166 , '' , 'bold' , 'bold')
call s:hi('pythonError' , 195 , '' , 'none' , 'none')
call s:hi('pythonIndentError' , 196 , '' , 'none' , 'none')
call s:hi('pythonSpaceError' , 196 , '' , 'none' , 'none')
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ALE
hi link ALEErrorSign Error
hi link ALEWarningSign Warning
" vim-easymotion
call s:hi('EasyMotionTarget' , 76 , '' , 'bold' , 'bold')
call s:hi('EasyMotionTarget2First' , 162 , '' , 'bold' , 'bold')
call s:hi('EasyMotionTarget2Second' , 69 , '' , 'bold' , 'bold')
" vim-markdown
call s:hi('htmlH1' , 68 , '' , 'bold' , 'bold')
call s:hi('htmlH2' , 36 , '' , 'bold' , 'bold')
call s:hi('htmlH3' , 114 , '' , 'bold' , 'bold')
call s:hi('htmlH4' , 178 , '' , 'bold' , 'bold')
call s:hi('htmlH5' , 68 , '' , 'None' , 'None')
call s:hi('htmlH6' , 36 , '' , 'None' , 'None')
" vim-indent-guides
let g:indent_guides_auto_colors = 0
call s:hi('IndentGuidesOdd' , '' , 237 , 'none' , 'none')
call s:hi('IndentGuidesEven' , '' , 239 , 'none' , 'none')
" vim-gitgutter
call s:hi('GitGutterAdd' , 36 , '' , 'none' , 'none')
call s:hi('GitGutterChange' , 178 , '' , 'none' , 'none')
call s:hi('GitGutterDelete' , 160 , '' , 'none' , 'none')
call s:hi('GitGutterChangeDelete' , 140 , '' , 'none' , 'none')
" vim-signify
call s:hi('SignifySignAdd' , 36 , '' , 'none' , 'none')
call s:hi('SignifySignChange' , 178 , '' , 'none' , 'none')
call s:hi('SignifySignDelete' , 160 , '' , 'none' , 'none')
call s:hi('SignifySignChangeDelete', 140 , '' , 'none' , 'none')
" vim-startify
hi link StartifyFile Normal
call s:hi('StartifyHeader' , 177 , '' , 'none' , 'none')
call s:hi('startifySection' , 68 , '' , 'bold' , 'bold')
" YouCompleteMe
call s:hi('YcmErrorSection' , 249 , 5 , 'none' , 'none')
call s:hi('YcmWarningSection' , 249 , 60 , 'none' , 'none')
" vim-leader-guide
hi link LeaderGuideDesc Normal
call s:hi('LeaderGuideKeys' , 169 , '' , 'bold' , 'bold')
call s:hi('LeaderGuideBrackets' , 36 , '' , 'none' , 'none')
" NERDTree
call s:hi('NERDTreeCWD' , 169 , '' , 'bold' , 'bold')
call s:hi('NERDTreeUp' , 68 , '' , 'bold' , 'bold')
call s:hi('NERDTreeDir' , 68 , '' , 'bold' , 'bold')
call s:hi('NERDTreeDirSlash' , 68 , '' , 'bold' , 'bold')
call s:hi('NERDTreeOpenable' , 68 , '' , 'bold' , 'bold')
call s:hi('NERDTreeClosable' , 68 , '' , 'bold' , 'bold')
call s:hi('NERDTreeExecFile' , 167 , '' , 'bold' , 'bold')
hi link NERDTreeLinkTarget Macro
" Tagbar
call s:hi('TagbarKind' , 169 , '' , 'bold' , 'bold')
call s:hi('TagbarScope' , 169 , '' , 'bold' , 'bold')
call s:hi('TagbarHighlight' , 16 , 36 , 'bold' , 'bold')
call s:hi('TagbarNestedKind' , 68 , '' , 'bold' , 'bold')
call s:hi('TagbarVisibilityPublic' , 34 , '' , 'none' , 'none')
" vim-signature
call s:hi('SignatureMarkText', 178, '', 'bold', 'bold')
" vim_current_word
call s:hi('CurrentWord' , '' , s:bg1 , 'underline' , 'underline')
call s:hi('CurrentWordTwins' , '' , s:bg1 , 'none' , 'none')
" quick-scope
call s:hi('QuickScopePrimary' , 155 , '' , 'underline' , 'underline')
call s:hi('QuickScopeSecondary' , 81 , '' , 'underline' , 'underline')
delf s:hi
unlet s:color256 s:colors s:bg
" Must be at the end, because of ctermbg=234 bug.
" https://groups.google.com/forum/#!msg/vim_dev/afPqwAFNdrU/nqh6tOM87QUJ
" 设置暗色调貌似会重置 Comment 的颜色
" set background=dark
endif
" } // end space-vim-dark
" 斜体 {
" 斜体需要终端支持, 如果不支持, 使用斜体部分可能显示异常
" 禁用选项 g:enableItalic 让异常显示恢复正常
if exists('g:enableItalic') && g:enableItalic
set t_ZH=[3m
set t_ZR=[23m
" 注释以斜体显示
hi Comment cterm=italic
endif
" }
if exists('g:enableStatusline') && g:enableStatusline
" Custom Status Line {
" Refer: https://github.com/liuchengxu/eleline.vim
let g:jobs = {}
function! S_buf_num()
let l:tnr = bufnr('%')
let l:wnr = winnr('$') > 1 ? '-'.winnr() : ''
let l:bnr = len(filter(range(1, bufnr('$')), 'buflisted(v:val)'))
let l:bnr = l:bnr > 1 ? '/'.l:bnr : ''
return l:tnr.l:wnr.l:bnr
endfunction
function! S_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! S_full_path()
return &filetype ==# 'startify' ? '' : expand('%:p:t')
endfunction
function! S_ale_error()
if exists('g:loaded_ale')
let l:counts = ale#statusline#Count(bufnr(''))
return l:counts[0] == 0 ? '' : '•'.l:counts[0]
endif
return ''
endfunction
function! S_ale_warning()
if exists('g:loaded_ale')
let l:counts = ale#statusline#Count(bufnr(''))
return l:counts[1] == 0 ? '' : '•'.l:counts[1]
endif
return ''
endfunction
function! IsGitDir(path) abort
let path = substitute(a:path, '[\/]$', '', '') . '/'
return getfsize(path.'HEAD') > 10 && (
\ isdirectory(path.'objects') && isdirectory(path.'refs') ||
\ getftype(path.'commondir') ==# 'file')
endfunction
function! ExtractGitDir(path) abort
if a:path == '' || a:path == '/' | return '' | endif
let l:path = a:path
if !isdirectory(a:path) | let l:path = fnamemodify(l:path, ':h') | endif
while l:path !=# '/'
let dir = substitute(l:path, '[\/]$', '', '') . '/.git'
if IsGitDir(dir)
return l:path
endif
let l:path = fnamemodify(l:path, ':h')
endwhile
return ''
endfunction
function! s:is_tmp_file()
if !empty(&buftype) | return 1 | endif
if &filetype ==# 'gitcommit' | return 1 | endif
if expand('%:p') =~# '^/tmp' | return 1 | endif
endfunction
function! s:SetGitStatus(root, str)
let buf_list = filter(range(1, bufnr('$')), 'bufexists(v:val)')
for nr in buf_list
let path = fnamemodify(resolve(bufname(nr)), ':p')
if match(path, a:root) >= 0
call setbufvar(nr, 's_branch', a:str)
break
endif
endfor
redraws!
endfunction
function! s:branch(channel, message) abort
if a:message =~ "^* "
let l:branch = substitute(a:message, '*', ' ⎇ ', '')
call s:SetGitStatus(s:cwd, l:branch.' ')
endif
endfunction
function! BranchExit(job, exit) abort
let l:job_id = matchstr(string(a:job), '\d\+')
if !has_key(g:jobs, l:job_id) | return | endif
call remove(g:jobs, l:job_id)
endfunction
function! s:JobHandler(job_id, data, event) dict abort
if !has_key(g:jobs, a:job_id) | return | endif
if v:dying | return | endif
let l:cur_branch = join(filter(self.stdout, 'v:val =~ "*"'))
if !empty(l:cur_branch)
let l:branch = substitute(l:cur_branch, '*', ' ⎇ ', '')
call s:SetGitStatus(self.cwd, l:branch.' ')
else
let errs = join(self.stderr)
if !empty(errs) | echoerr errs | endif
endif
call remove(g:jobs, a:job_id)
endfunction
function! S_branch(...) abort
if s:is_tmp_file() | return '' | endif
let reload = get(a:, 1, 0) == 1
if exists('b:s_branch') && !reload | return b:s_branch | endif
if !exists('*ExtractGitDir') | return '' | endif
let roots = values(g:jobs)
let dir = ExtractGitDir(resolve(expand('%:p')))
if empty(dir) | return '' | endif
let b:git_dir = dir
let root = dir
if index(roots, root) >= 0 | return '' | endif
let argv = add(has('win32') ? ['cmd', '/c']: ['bash', '-c'], 'cd '.root.';git branch')
if exists('*job_start')
let job = job_start(argv, {'out_io': 'pipe', 'err_io':'null', 'out_cb': function('s:branch'), 'exit_cb': 'BranchExit'})
if job_status(job) == 'fail' | return '' | endif
let s:cwd = root
let job_id = matchstr(job, '\d\+')
let g:jobs[job_id] = root
elseif exists('*jobstart')
let job_id = jobstart(argv, {
\ 'cwd': root,
\ 'stdout_buffered': v:true,
\ 'stderr_buffered': v:true,
\ 'on_exit': function('s:JobHandler')
\ })
if job_id == 0 || job_id == -1 | return '' | endif
let g:jobs[job_id] = root
elseif exists('g:loaded_fugitive')
let l:head = fugitive#head()
let l:symbol = ' ⎇ '
return empty(l:head) ? '' : l:symbol.l:head . ' '
endif
return ''
endfunction
function! S_git()
let l:summary = [0, 0, 0]
if exists('b:sy')
let l:summary = b:sy.stats
elseif exists('b:gitgutter.summary')
let l:summary = b:gitgutter.summary
endif
if max(l:summary) > 0
return ' +'.l:summary[0].' ~'.l:summary[1].' -'.l:summary[2].' '
endif
return ''
endfunction
function! s:MyStatusLine()
let l:buf_num = '%1* '.(has('gui_running')?'%n':'%{S_buf_num()}')." ❖ %*"
let l:paste = "%#paste#%{&paste?'PASTE ':''}%*"
let l:fp = '%4* %{S_full_path()} %*'
let l:branch = '%6*%{S_branch()}%*'
let l:gutter = '%{S_git()}'
let l:ale_e = '%#ale_error#%{S_ale_error()}%*'
let l:ale_w = '%#ale_warning#%{S_ale_warning()}%*'
let l:fs = '%3* %{S_file_size(@%)} %*'
let l:m_r_f = '%7* %m%r%y %*'
let l:enc = " %{''.(&fenc!=''?&fenc:&enc).''}"."%{(&bomb?'[BOM]':'')}"."%{'['.&ff.']'} %*"
let l:pct = "%9* %P %*"
let l:pos = '%8* %l/%L:%c '
return l:buf_num.l:paste.'%<'.l:fs.l:fp.l:branch.l:gutter.l:ale_e.l:ale_w
\ .'%='.l:m_r_f.l:enc.l:pct.l:pos
endfunction
let s:colors = {
\ 140 : '#af87d7', 149 : '#99cc66', 160 : '#d70000',
\ 171 : '#d75fd7', 178 : '#ffbb7d', 184 : '#ffe920',
\ 208 : '#ff8700', 232 : '#333300', 197 : '#cc0033',
\ 214 : '#ffff66',
\
\ 235 : '#262626', 236 : '#303030', 237 : '#3a3a3a',
\ 238 : '#444444', 239 : '#4e4e4e', 240 : '#585858',
\ 241 : '#606060', 242 : '#666666', 243 : '#767676',
\ 244 : '#808080', 245 : '#8a8a8a', 246 : '#949494',
\ 247 : '#9e9e9e', 248 : '#a8a8a8', 249 : '#b2b2b2',
\ 250 : '#bcbcbc', 251 : '#c6c6c6', 252 : '#d0d0d0',
\ 253 : '#dadada', 254 : '#e4e4e4', 255 : '#eeeeee',
\ }
function! s:hi(group, fg, bg, ...)
execute printf('hi %s ctermfg=%d guifg=%s ctermbg=%d guibg=%s',
\ a:group, a:fg, s:colors[a:fg], a:bg, s:colors[a:bg])
if a:0 == 1
execute printf('hi %s cterm=%s gui=%s', a:group, a:1, a:1)
endif
endfunction
if !exists('g:eleline_background')
let s:normal_bg = synIDattr(synIDtrans(hlID('Normal')), "bg", 'cterm')
if s:normal_bg >= 233 && s:normal_bg <= 243
let s:bg = s:normal_bg
else
let s:bg = 235
endif
else
let s:bg = g:eleline_background
endif
" Don't change in gui mode
if has('termguicolors') && &termguicolors
let s:bg = 235
endif
function! s:hi_statusline()
call s:hi('User1' , 232 , 178 )
call s:hi('paste' , 232 , 178 , 'bold')
call s:hi('User2' , 178 , s:bg+8 )
call s:hi('User3' , 250 , s:bg+6 )
call s:hi('User4' , 171 , s:bg+4 , 'bold' )
call s:hi('User5' , 208 , s:bg+3 )
call s:hi('User6' , 184 , s:bg+2 , 'bold' )
call s:hi('gutter' , 184 , s:bg+2)
call s:hi('ale_error' , 197 , s:bg+2)
call s:hi('ale_warning' , 214 , s:bg+2)
call s:hi('StatusLine' , 140 , s:bg+2 , 'none')
call s:hi('User7' , 249 , s:bg+3 )
call s:hi('User8' , 250 , s:bg+4 )
call s:hi('User9' , 251 , s:bg+5 )
endfunction
function! s:InsertStatuslineColor(mode)
if a:mode == 'i'
call s:hi('User1' , 251 , s:bg+8 )
elseif a:mode == 'r'
call s:hi('User1' , 232 , 160 )
else
call s:hi('User1' , 232 , 178 )
endif
endfunction
" Note that the "%!" expression is evaluated in the context of the
" current window and buffer, while %{} items are evaluated in the
" context of the window that the statusline belongs to.
function! s:SetStatusline(...) abort
call S_branch(1)
let &l:statusline = s:MyStatusLine()
" User-defined highlightings shoule be put after colorscheme command.
call s:hi_statusline()
endfunction
if exists('*timer_start')
call timer_start(100, function('s:SetStatusline'))
else
call s:SetStatusline()
endif
augroup statusline
autocmd!
autocmd User GitGutter,Startified,LanguageClientStarted call s:SetStatusline()
" Change colors for insert mode
autocmd InsertLeave * call s:hi('User1' , 232 , 178 )